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
This commit is contained in:
Stefan Eissing 2024-03-07 11:05:53 +01:00 committed by Daniel Stenberg
parent 800617fac8
commit a586b8ca40
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
10 changed files with 14 additions and 36 deletions

View File

@ -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);
}

View File

@ -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;

View File

@ -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);
}

View File

@ -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
*************************************************************/

View File

@ -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)

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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)

View File

@ -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