]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
transfer: limit Windows SO_SNDBUF updates to once a second
authorJay Satiro <raysatiro@yahoo.com>
Sun, 26 Feb 2023 08:44:38 +0000 (03:44 -0500)
committerJay Satiro <raysatiro@yahoo.com>
Wed, 1 Mar 2023 06:15:28 +0000 (01:15 -0500)
- Change readwrite_upload() to call win_update_buffer_size() no more
  than once a second to update SO_SNDBUF (send buffer limit).

Prior to this change during an upload readwrite_upload() could call
win_update_buffer_size() anywhere from hundreds of times per second to
an extreme test case of 100k per second (which is likely due to a bug,
see #10618). In the latter case WPA profiler showed
win_update_buffer_size was the highest capture count in
readwrite_upload. In any case the calls were excessive and unnecessary.

Ref: https://github.com/curl/curl/pull/2762

Closes https://github.com/curl/curl/pull/10611

lib/transfer.c
lib/urldata.h

index 69df214ce47f22f74dcdd632968f4de07d8a00fe..27843f50cc1f0cdd18d1e0b78a95f46fc28e76b9 100644 (file)
@@ -980,7 +980,15 @@ static CURLcode readwrite_upload(struct Curl_easy *data,
     if(result)
       return result;
 
-    win_update_buffer_size(conn->writesockfd);
+#if defined(WIN32) && defined(USE_WINSOCK)
+    {
+      struct curltime n = Curl_now();
+      if(Curl_timediff(n, k->last_sndbuf_update) > 1000) {
+        win_update_buffer_size(conn->writesockfd);
+        k->last_sndbuf_update = n;
+      }
+    }
+#endif
 
     if(k->pendingheader) {
       /* parts of what was sent was header */
index ca8e3074d70b15920348c52c6adec4298b9779d7..d7d104d419dfefe6480c8488b5d50ade7289c40b 100644 (file)
@@ -686,6 +686,10 @@ struct SingleRequest {
   } p;
 #ifndef CURL_DISABLE_DOH
   struct dohdata *doh; /* DoH specific data for this request */
+#endif
+#if defined(WIN32) && defined(USE_WINSOCK)
+  struct curltime last_sndbuf_update;  /* last time readwrite_upload called
+                                          win_update_buffer_size */
 #endif
   unsigned char setcookies;
   unsigned char writer_stack_depth; /* Unencoding stack depth. */