aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-11-18 19:44:36 -0800
committerJunio C Hamano <gitster@pobox.com>2012-11-18 19:44:36 -0800
commit8b56a4702209a6054bd1eb89e9d63abfd6f4cf2e (patch)
treef431ee2c5b4a01d619419909b0cfeeaf222a447d
parentb98769e06e50009b1b7b1ca465c0f3b0cf0f6fa3 (diff)
parent7202b81ffccf89605ce2726ff9d63202b5f1da7f (diff)
downloadgit-8b56a4702209a6054bd1eb89e9d63abfd6f4cf2e.tar.gz
git-8b56a4702209a6054bd1eb89e9d63abfd6f4cf2e.tar.xz
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
-rw-r--r--http.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/http.c b/http.c
index df9bb7108..f9a9de141 100644
--- a/http.c
+++ b/http.c
@@ -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);
}
}