]> granicus.if.org Git - curl/commitdiff
curl: avoid uncessary libcurl timeouts (in parallel mode)
authorDaniel Stenberg <daniel@haxx.se>
Mon, 29 Jul 2019 06:50:25 +0000 (08:50 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 29 Jul 2019 12:57:57 +0000 (14:57 +0200)
When curl_multi_wait() returns OK without file descriptors to wait for,
it might already have done a long timeout.

Closes #4159

src/tool_operate.c

index 68cd11c56dcae3169e0519f305379f2769619816..18adf1046be0adc5c4362bf259886d735409eecf 100644 (file)
@@ -1972,14 +1972,17 @@ static CURLcode parallel_transfers(struct GlobalConfig *global,
 
   while(!done && !mcode && still_running) {
     int numfds;
+    struct timeval before = tvnow();
+    long delta;
 
     mcode = curl_multi_wait(multi, NULL, 0, 1000, &numfds);
+    delta = tvdiff(tvnow(), before);
 
     if(!mcode) {
-      if(!numfds) {
+      if(!numfds && (delta < 30)) {
         long sleep_ms;
 
-        /* If it returns without any filedescriptor instantly, we need to
+        /* If it returns without any file descriptor instantly, we need to
            avoid busy-looping during periods where it has nothing particular
            to wait for */
         curl_multi_timeout(multi, &sleep_ms);