Browse Source

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
Stefan Eissing 1 month ago
parent
commit
a586b8ca40
10 changed files with 14 additions and 36 deletions
  1. 3 3
      lib/ftp.c
  2. 0 5
      lib/http.c
  3. 2 2
      lib/sendf.c
  4. 0 8
      lib/url.c
  5. 0 2
      lib/urldata.h
  6. 3 3
      lib/vssh/libssh.c
  7. 3 3
      lib/vssh/libssh2.c
  8. 3 3
      lib/vssh/wolfssh.c
  9. 0 5
      lib/ws.c
  10. 0 2
      lib/ws.h

+ 3 - 3
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);
     }
 

+ 0 - 5
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;

+ 2 - 2
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);
   }
 

+ 0 - 8
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
    *************************************************************/

+ 0 - 2
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)

+ 3 - 3
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);
         }
 

+ 3 - 3
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);
         }
 

+ 3 - 3
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);
         }
 

+ 0 - 5
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)

+ 0 - 2
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