* Fix potential hang in https handshake (v2).
@ 2012-10-18 23:27 szager
2012-10-19 0:33 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: szager @ 2012-10-18 23:27 UTC (permalink / raw)
To: git; +Cc: gitster, sop
>From aa77ab3dd5b98a5786ac158528f45355fc0ddbc3 Mon Sep 17 00:00:00 2001
From: Stefan Zager <szager@google.com>
Date: Thu, 18 Oct 2012 16:23:53 -0700
Subject: [PATCH] Fix potential hang in https handshake.
It will sometimes happen that curl_multi_fdset() doesn't
return any file descriptors. In that case, it's recommended
that the application sleep for a short time before running
curl_multi_perform() again.
http://curl.haxx.se/libcurl/c/curl_multi_fdset.html
Signed-off-by: Stefan Zager <szager@google.com>
---
http.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/http.c b/http.c
index df9bb71..e8aba7f 100644
--- a/http.c
+++ b/http.c
@@ -630,6 +630,10 @@ void run_active_slot(struct active_request_slot *slot)
FD_ZERO(&writefds);
FD_ZERO(&excfds);
curl_multi_fdset(curlm, &readfds, &writefds, &excfds, &max_fd);
+ if (max_fd < 0) {
+ select_timeout.tv_sec = 0;
+ select_timeout.tv_usec = 50000;
+ }
select(max_fd+1, &readfds, &writefds, &excfds, &select_timeout);
}
--
1.7.7.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: Fix potential hang in https handshake (v2).
2012-10-18 23:27 Fix potential hang in https handshake (v2) szager
@ 2012-10-19 0:33 ` Junio C Hamano
2012-10-19 0:37 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2012-10-19 0:33 UTC (permalink / raw)
To: szager; +Cc: git, sop
szager@google.com writes:
> From aa77ab3dd5b98a5786ac158528f45355fc0ddbc3 Mon Sep 17 00:00:00 2001
> From: Stefan Zager <szager@google.com>
> Date: Thu, 18 Oct 2012 16:23:53 -0700
> Subject: [PATCH] Fix potential hang in https handshake.
Please don't do the above (as usual ;-)
> It will sometimes happen that curl_multi_fdset() doesn't
> return any file descriptors. In that case, it's recommended
> that the application sleep for a short time before running
> curl_multi_perform() again.
>
> http://curl.haxx.se/libcurl/c/curl_multi_fdset.html
>
> Signed-off-by: Stefan Zager <szager@google.com>
> ---
The above sounds like "the code is doing something against a
recommended practice", but is there a user-visible symptom due to
this?
We end up calling select() without any bit set in fds, so it would
become micro-sleep of select_timeout in such a case, but as far as I
can see, the existing code either
* does not select() and keeps polling step_active_slots() without
delay, when curl_timeout gives a 0 return value; or
* sets 50ms timeout or whatever negative value derived from
curl_timeout when the returned value is not 0 nor -1.
Is the symptom that select(), when given a negative timeout and no
fd to wake it, sleeps forever (or "loooong time, taking that negative
value as if it is a large unsigned long") or something?
Thanks.
> http.c | 4 ++++
> 1 files changed, 4 insertions(+), 0 deletions(-)
>
> diff --git a/http.c b/http.c
> index df9bb71..e8aba7f 100644
> --- a/http.c
> +++ b/http.c
> @@ -630,6 +630,10 @@ void run_active_slot(struct active_request_slot *slot)
> FD_ZERO(&writefds);
> FD_ZERO(&excfds);
> curl_multi_fdset(curlm, &readfds, &writefds, &excfds, &max_fd);
> + if (max_fd < 0) {
> + select_timeout.tv_sec = 0;
> + select_timeout.tv_usec = 50000;
> + }
>
> select(max_fd+1, &readfds, &writefds, &excfds, &select_timeout);
> }
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Fix potential hang in https handshake (v2).
2012-10-19 0:33 ` Junio C Hamano
@ 2012-10-19 0:37 ` Junio C Hamano
0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2012-10-19 0:37 UTC (permalink / raw)
To: szager; +Cc: git, sop
Junio C Hamano <gitster@pobox.com> writes:
> We end up calling select() without any bit set in fds, so it would
> become micro-sleep of select_timeout in such a case, but as far as I
> can see, the existing code either
>
> * does not select() and keeps polling step_active_slots() without
> delay, when curl_timeout gives a 0 return value; or
>
> * sets 50ms timeout or whatever negative value derived from
> curl_timeout when the returned value is not 0 nor -1.
>
> Is the symptom that select(), when given a negative timeout and no
> fd to wake it, sleeps forever (or "loooong time, taking that negative
> value as if it is a large unsigned long") or something?
Addendum.
What I am trying to get at are (1) three line description I can put
in the release notes for this fix when it is merged to the
maintenance track, and (2) a feel of how often this happens and how
bad the damage is.
The latter helps us judge if this "do the normal thing, but if in a
rare case where we do not find any fds, patch it up to proceed" is a
better approach over your original.
Thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-10-19 0:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-18 23:27 Fix potential hang in https handshake (v2) szager
2012-10-19 0:33 ` Junio C Hamano
2012-10-19 0:37 ` Junio C Hamano
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).