From: Stefan Eissing Date: Thu, 7 Mar 2024 10:05:53 +0000 (+0100) Subject: lib: client reader polish X-Git-Tag: curl-8_7_0~47 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a586b8ca4045292bf2443098d7f1a93cfe2dc620;p=thirdparty%2Fcurl.git lib: client reader polish - seek_func/seek_client, use transfer values only - remove copies held in `struct connectdata`, use only ever `data->set.seek_func` - resolves possible issues in multiuse connections - new mime post reader eliminates need to ever overwriting this - websockets, remove empty Curl_ws_done() function Closes #13079 --- diff --git a/lib/ftp.c b/lib/ftp.c index 2511bd4b61..29a1476da4 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -1683,10 +1683,10 @@ static CURLcode ftp_state_ul_setup(struct Curl_easy *data, append = TRUE; /* Let's read off the proper amount of bytes from the input. */ - if(conn->seek_func) { + if(data->set.seek_func) { Curl_set_in_callback(data, true); - seekerr = conn->seek_func(conn->seek_client, data->state.resume_from, - SEEK_SET); + seekerr = data->set.seek_func(data->set.seek_client, + data->state.resume_from, SEEK_SET); Curl_set_in_callback(data, false); } diff --git a/lib/http.c b/lib/http.c index d50b099c77..058d079f49 100644 --- a/lib/http.c +++ b/lib/http.c @@ -1249,16 +1249,11 @@ CURLcode Curl_http_done(struct Curl_easy *data, data->state.authhost.multipass = FALSE; data->state.authproxy.multipass = FALSE; - /* set the proper values (possibly modified on POST) */ - conn->seek_func = data->set.seek_func; /* restore */ - conn->seek_client = data->set.seek_client; /* restore */ - if(!http) return CURLE_OK; Curl_dyn_reset(&data->state.headerb); Curl_hyper_done(data); - Curl_ws_done(data); if(status) return status; diff --git a/lib/sendf.c b/lib/sendf.c index 5bec063d94..9610f70dad 100644 --- a/lib/sendf.c +++ b/lib/sendf.c @@ -724,9 +724,9 @@ static CURLcode cr_in_resume_from(struct Curl_easy *data, if(ctx->read_len) return CURLE_READ_ERROR; - if(data->conn->seek_func) { + if(data->set.seek_func) { Curl_set_in_callback(data, true); - seekerr = data->conn->seek_func(data->conn->seek_client, offset, SEEK_SET); + seekerr = data->set.seek_func(data->set.seek_client, offset, SEEK_SET); Curl_set_in_callback(data, false); } diff --git a/lib/url.c b/lib/url.c index b305765976..f457e27664 100644 --- a/lib/url.c +++ b/lib/url.c @@ -353,7 +353,6 @@ CURLcode Curl_init_userdefined(struct Curl_easy *data) set->fread_func_set = (curl_read_callback)fread; set->is_fread_set = 0; - set->seek_func = ZERO_NULL; set->seek_client = ZERO_NULL; set->filesize = -1; /* we don't know the size */ @@ -3765,13 +3764,6 @@ static CURLcode create_conn(struct Curl_easy *data, /* Continue connectdata initialization here. */ - /* - * Inherit the proper values from the urldata struct AFTER we have arranged - * the persistent connection stuff - */ - conn->seek_func = data->set.seek_func; - conn->seek_client = data->set.seek_client; - /************************************************************* * Resolve the address of the server or proxy *************************************************************/ diff --git a/lib/urldata.h b/lib/urldata.h index b9e5702758..2e3cf345cf 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -874,8 +874,6 @@ struct connectdata { #endif /* however, some of them are ftp specific. */ struct Curl_llist easyq; /* List of easy handles using this connection */ - curl_seek_callback seek_func; /* function that seeks the input */ - void *seek_client; /* pointer to pass to the seek() above */ /*************** Request - specific items ************/ #if defined(USE_WINDOWS_SSPI) && defined(SECPKG_ATTR_ENDPOINT_BINDINGS) diff --git a/lib/vssh/libssh.c b/lib/vssh/libssh.c index 7cfc950216..da7ce6ad98 100644 --- a/lib/vssh/libssh.c +++ b/lib/vssh/libssh.c @@ -1292,10 +1292,10 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block) position. */ if(data->state.resume_from > 0) { /* Let's read off the proper amount of bytes from the input. */ - if(conn->seek_func) { + if(data->set.seek_func) { Curl_set_in_callback(data, true); - seekerr = conn->seek_func(conn->seek_client, data->state.resume_from, - SEEK_SET); + seekerr = data->set.seek_func(data->set.seek_client, + data->state.resume_from, SEEK_SET); Curl_set_in_callback(data, false); } diff --git a/lib/vssh/libssh2.c b/lib/vssh/libssh2.c index 073c6873db..3cfbe126c6 100644 --- a/lib/vssh/libssh2.c +++ b/lib/vssh/libssh2.c @@ -2142,10 +2142,10 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block) position. */ if(data->state.resume_from > 0) { /* Let's read off the proper amount of bytes from the input. */ - if(conn->seek_func) { + if(data->set.seek_func) { Curl_set_in_callback(data, true); - seekerr = conn->seek_func(conn->seek_client, data->state.resume_from, - SEEK_SET); + seekerr = data->set.seek_func(data->set.seek_client, + data->state.resume_from, SEEK_SET); Curl_set_in_callback(data, false); } diff --git a/lib/vssh/wolfssh.c b/lib/vssh/wolfssh.c index c6b94fd50d..11275910a1 100644 --- a/lib/vssh/wolfssh.c +++ b/lib/vssh/wolfssh.c @@ -625,10 +625,10 @@ static CURLcode wssh_statemach_act(struct Curl_easy *data, bool *block) if(data->state.resume_from > 0) { /* Let's read off the proper amount of bytes from the input. */ int seekerr = CURL_SEEKFUNC_OK; - if(conn->seek_func) { + if(data->set.seek_func) { Curl_set_in_callback(data, true); - seekerr = conn->seek_func(conn->seek_client, data->state.resume_from, - SEEK_SET); + seekerr = data->set.seek_func(data->set.seek_client, + data->state.resume_from, SEEK_SET); Curl_set_in_callback(data, false); } diff --git a/lib/ws.c b/lib/ws.c index 263299761f..5bc5eccc48 100644 --- a/lib/ws.c +++ b/lib/ws.c @@ -1163,11 +1163,6 @@ static CURLcode ws_setup_conn(struct Curl_easy *data, } -void Curl_ws_done(struct Curl_easy *data) -{ - (void)data; -} - static CURLcode ws_disconnect(struct Curl_easy *data, struct connectdata *conn, bool dead_connection) diff --git a/lib/ws.h b/lib/ws.h index 5f40d4528b..baa77b4424 100644 --- a/lib/ws.h +++ b/lib/ws.h @@ -75,7 +75,6 @@ struct websocket { CURLcode Curl_ws_request(struct Curl_easy *data, REQTYPE *req); CURLcode Curl_ws_accept(struct Curl_easy *data, const char *mem, size_t len); -void Curl_ws_done(struct Curl_easy *data); extern const struct Curl_handler Curl_handler_ws; #ifdef USE_SSL @@ -85,7 +84,6 @@ extern const struct Curl_handler Curl_handler_wss; #else #define Curl_ws_request(x,y) CURLE_OK -#define Curl_ws_done(x) Curl_nop_stmt #define Curl_ws_free(x) Curl_nop_stmt #endif