git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH v1] Pull, Fetch, and Push hang for 2 minutes over https when connecting to localhost.
@ 2013-12-08 21:53 Rick Burgstaler
  0 siblings, 0 replies; only message in thread
From: Rick Burgstaler @ 2013-12-08 21:53 UTC (permalink / raw
  To: git@vger.kernel.org; +Cc: szager@google.com, mika.fischer@zoopnet.de

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 <rburgstaler@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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2013-12-08 21:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-08 21:53 [PATCH v1] Pull, Fetch, and Push hang for 2 minutes over https when connecting to localhost Rick Burgstaler

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).