]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
lib: client reader polish
authorStefan Eissing <stefan@eissing.org>
Thu, 7 Mar 2024 10:05:53 +0000 (11:05 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 8 Mar 2024 12:11:17 +0000 (13:11 +0100)
- 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

lib/ftp.c
lib/http.c
lib/sendf.c
lib/url.c
lib/urldata.h
lib/vssh/libssh.c
lib/vssh/libssh2.c
lib/vssh/wolfssh.c
lib/ws.c
lib/ws.h

index 2511bd4b6110b62a3d65f4333550ccbc935b3bf0..29a1476da4c19d67b7e199bfcc280073c51a09f7 100644 (file)
--- 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);
     }
 
index d50b099c77ebfc59033f05e8d94cf8008b5fc987..058d079f498bab909b28ae327781258ae0b6d1d9 100644 (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;
index 5bec063d94c7168703ad6e6eb9a68ef2eaa4595b..9610f70dad3ccb4a56ba78c3b2484e24d553ea23 100644 (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);
   }
 
index b30576597642d4dea149343a9abbec38d4432a62..f457e2766405d9116a7668318ced4d020071b2d7 100644 (file)
--- 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
    *************************************************************/
index b9e57027580838001ef04b51ebcfc0e0cd81f09c..2e3cf345cfc8a98aba5dfeea78d8a8469fddf1fa 100644 (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)
index 7cfc950216625be151ebf956a47fb1552bec5ba8..da7ce6ad9890e1b14a1f4bce418e12f09a4f9b9a 100644 (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);
         }
 
index 073c6873db40ca0d00a1b65226f6a4802afbc975..3cfbe126c69df39bb6c925894247f5bb48107e13 100644 (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);
         }
 
index c6b94fd50d334eef4fc4ee00db71b5bf65643008..11275910a1f92e61ea475cace44a45881dfa7d76 100644 (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);
         }
 
index 263299761f8dbf3070534f6e74903280bb37e484..5bc5eccc48b317d7b931434ef37aef06ca254e38 100644 (file)
--- 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)
index 5f40d4528b551c0d94aa86740eb04ea4ae1ee34e..baa77b44249875d8e90b2e361fd61c83b7a2ddf0 100644 (file)
--- 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