Bug description: On Windows, when the git client is attempting to communicate 
via https to an apache server that happens to be on the same machine 
(localhost), the client connection will hang for about 2 minutes before 
completing.  Connecting via https to non-localhost git server returns 
immediately and works as desired.  It is not known as to whether this is an 
issue in other environments than Windows. 

This behavior was observed starting with msysgit version 1.8.3 and newer and 
was a result of msysgit updating the curl library from version 7.26 to version 
7.28 and the problem still exists in curl version 7.33.  The problem was 
occurring because curl_multi_timeout() was returning a value of 148797 under 
this circumstance which posed a greater than 2 minute wait before timing out in 
the call to select().  Examples (curl\docs\examples\fopen.c & 
curl\docs\examples\multi-app.c) provided with the curl library for how to use 
curl_multi_timeout() setup the timeout slightly different than how it is being 
done here.  Curl examples basically clip all timeouts returned from 
curl_multi_timeout() at one second.  The changes made with this revision change 
it to follow the same clipping logic as used by the curl examples.

It should be noted that this problem appears to be very similar to a problem 
Stefan Zager was having where a large timeout was returned when an invalid file 
descriptor was returned.

Another thought on how to resolve this issue would have been to track down why 
the curl_multi_timeout() method is returning such a large value  in the curl 
library and resolve it there, but being as though examples written for how to 
use curl_multi_timeout() properly do not exhibit this problem in the first 
place it most likely makes more sense to modify the calling logic to fix the 
problem. 

Signed-off-by: Rick Burgstaler <rburgsta...@yahoo.com>

---

diff --git a/http.c b/http.c
index 8284837..314d091 100644
--- a/http.c
+++ b/http.c
@@ -640,15 +640,18 @@ void run_active_slot(struct active_request_slot *slot)
 
 if (slot->in_use) {
 #if LIBCURL_VERSION_NUM >= 0x070f04
-long curl_timeout;
+long curl_timeout = -1;
+
+/* set a suitable timeout */
+select_timeout.tv_sec = 1;
+select_timeout.tv_usec = 0;
+
 curl_multi_timeout(curlm, &curl_timeout);
-if (curl_timeout == 0) {
-continue;
-} else if (curl_timeout == -1) {
-select_timeout.tv_sec  = 0;
-select_timeout.tv_usec = 50000;
-} else {
-select_timeout.tv_sec  =  curl_timeout / 1000;
+if(curl_timeout >= 0) {
+  select_timeout.tv_sec = curl_timeout / 1000;
+  if(select_timeout.tv_sec > 1)
+select_timeout.tv_sec = 1;
+  else
 select_timeout.tv_usec = (curl_timeout % 1000) * 1000;
 }
 #else

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to