Skip to content

Commit 8b56a47

Browse files
committed
Merge branch 'sz/maint-curl-multi-timeout' into maint
Sometimes curl_multi_timeout() function suggested a wrong timeout value when there is no file descriptors to wait on and the http transport ended up sleeping for minutes in select(2) system call. A workaround has been added for this. * sz/maint-curl-multi-timeout: Fix potential hang in https handshake
2 parents b98769e + 7202b81 commit 8b56a47

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

http.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,18 @@ void run_active_slot(struct active_request_slot *slot)
631631
FD_ZERO(&excfds);
632632
curl_multi_fdset(curlm, &readfds, &writefds, &excfds, &max_fd);
633633

634+
/*
635+
* It can happen that curl_multi_timeout returns a pathologically
636+
* long timeout when curl_multi_fdset returns no file descriptors
637+
* to read. See commit message for more details.
638+
*/
639+
if (max_fd < 0 &&
640+
(select_timeout.tv_sec > 0 ||
641+
select_timeout.tv_usec > 50000)) {
642+
select_timeout.tv_sec = 0;
643+
select_timeout.tv_usec = 50000;
644+
}
645+
634646
select(max_fd+1, &readfds, &writefds, &excfds, &select_timeout);
635647
}
636648
}

0 commit comments

Comments
 (0)