summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2019-07-29 08:50:25 +0200
committerDaniel Stenberg <daniel@haxx.se>2019-07-29 11:21:45 +0200
commit49624ffba205c6f5072c3ad10d617fddd522761c (patch)
tree04f94475b5bf08e7b9a746e1571760cc583f8ea0
parent9736ac03ab3c9b352437dc1cb6cb4568bbf1a711 (diff)
downloadcurl-bagder/curl-parallel-timeout.tar.gz
curl: avoid uncessary libcurl timeouts (in parallel mode)bagder/curl-parallel-timeout
When curl_multi_wait() returns OK without file descriptors to wait for, it might already have done a long timeout.
-rw-r--r--src/tool_operate.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/tool_operate.c b/src/tool_operate.c
index 68cd11c56..18adf1046 100644
--- a/src/tool_operate.c
+++ b/src/tool_operate.c
@@ -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);