瀏覽代碼

transfer: limit Windows SO_SNDBUF updates to once a second

- 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
Jay Satiro 1 年之前
父節點
當前提交
0b84d0cf1b
共有 2 個文件被更改,包括 13 次插入1 次删除
  1. 9 1
      lib/transfer.c
  2. 4 0
      lib/urldata.h

+ 9 - 1
lib/transfer.c

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

+ 4 - 0
lib/urldata.h

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