diff options
author | Jeff King <peff@peff.net> | 2012-11-09 12:50:56 -0500 |
---|---|---|
committer | Jeff King <peff@peff.net> | 2012-11-09 12:50:56 -0500 |
commit | 23a50a1fb113b702012935ee8c6e945cf58edbd7 (patch) | |
tree | a32ffbe8fff59309754be09efb2bbe037f168b2d | |
parent | d9253f2bc8b17249a433494a54dbe0d22ae8c5d0 (diff) | |
parent | 7202b81ffccf89605ce2726ff9d63202b5f1da7f (diff) | |
download | git-23a50a1fb113b702012935ee8c6e945cf58edbd7.tar.gz |
Merge branch 'sz/maint-curl-multi-timeout'
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.
Detect this and reduce the wait timeout in such a case.
* sz/maint-curl-multi-timeout:
Fix potential hang in https handshake
-rw-r--r-- | http.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -631,6 +631,18 @@ void run_active_slot(struct active_request_slot *slot) FD_ZERO(&excfds); curl_multi_fdset(curlm, &readfds, &writefds, &excfds, &max_fd); + /* + * It can happen that curl_multi_timeout returns a pathologically + * long timeout when curl_multi_fdset returns no file descriptors + * to read. See commit message for more details. + */ + if (max_fd < 0 && + (select_timeout.tv_sec > 0 || + select_timeout.tv_usec > 50000)) { + select_timeout.tv_sec = 0; + select_timeout.tv_usec = 50000; + } + select(max_fd+1, &readfds, &writefds, &excfds, &select_timeout); } } |