1
0
mirror of https://github.com/moparisthebest/curl synced 2024-11-17 06:55:02 -05:00

curl: avoid uncessary libcurl timeouts (in parallel mode)

When curl_multi_wait() returns OK without file descriptors to wait for,
it might already have done a long timeout.

Closes #4159
This commit is contained in:
Daniel Stenberg 2019-07-29 08:50:25 +02:00
parent 802aa5ae27
commit a2ab576768
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -1972,14 +1972,17 @@ static CURLcode parallel_transfers(struct GlobalConfig *global,
while(!done && !mcode && still_running) { while(!done && !mcode && still_running) {
int numfds; int numfds;
struct timeval before = tvnow();
long delta;
mcode = curl_multi_wait(multi, NULL, 0, 1000, &numfds); mcode = curl_multi_wait(multi, NULL, 0, 1000, &numfds);
delta = tvdiff(tvnow(), before);
if(!mcode) { if(!mcode) {
if(!numfds) { if(!numfds && (delta < 30)) {
long sleep_ms; 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 avoid busy-looping during periods where it has nothing particular
to wait for */ to wait for */
curl_multi_timeout(multi, &sleep_ms); curl_multi_timeout(multi, &sleep_ms);