git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Fix potential hang in https handshake.

From
SZStefan Zager <szager@google.com>
Date
Oct 19, 2012, 20:37 UTC
Message-ID
<CAHOQ7J8D-8++vgMh=c0rcTtAKrhWUCQx2nSd_spBzFe=QdXwBw@mail.gmail.com>
In-Reply-To
<20121019202723.GA24184@sigill.intra.peff.net>
On Fri, Oct 19, 2012 at 1:27 PM, Jeff King <peff@peff.net> wrote:
Show 43 quoted lines
>
> On Fri, Oct 19, 2012 at 07:10:46AM -0700, Shawn O. Pearce wrote:
>
> > > IOW, it seems like we are _already_ following the advice referenced in
> > > curl's manpage. Is there some case I am missing? Confused...
> >
> > The issue with the current code is sometimes when libcurl is opening a
> > CONNECT style connection through an HTTP proxy it returns a crazy high
> > timeout (>240 seconds) and no fds. In this case Git waits forever.
> > Stefan observed that using a timeout of 50 ms in this situation to
> > poll libcurl is better, as it figures out a lot more quickly that it
> > is connected to the proxy and can issue the request.
>
> Ah. That sounds like a bug in curl to me. But either way, if we want to
> work around it, wouldn't the right thing be to override curl's timeout
> in that instance? Like:
>
> diff --git a/http.c b/http.c
> index df9bb71..cd07cdf 100644
> --- a/http.c
> +++ b/http.c
> @@ -631,6 +631,19 @@ void run_active_slot(struct active_request_slot *slot)
>                         FD_ZERO(&excfds);
>                         curl_multi_fdset(curlm, &readfds, &writefds, &excfds, &max_fd);
>
> +                       /*
> +                        * Sometimes curl will give a really long timeout for a
> +                        * CONNECT when there are no fds to read, but we can
> +                        * get better results by running curl_multi_perform
> +                        * more frequently.
> +                        */
> +                       if (maxfd < 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);
>                 }
>         }
>
> -Peff
I have no objection to this; any one else?
Stefan
Previous: Jeff KingNext: Jeff King
Message 7 of 10 in “Fix potential hang in https handshake.”
  1. szager@google.comOct 18, 2012
  2. Junio C HamanoOct 18, 2012
  3. Jeff KingOct 19, 2012
  4. Shawn PearceOct 19, 2012
  5. Daniel StenbergOct 19, 2012
  6. Jeff KingOct 19, 2012
  7. Stefan ZagerOct 19, 2012
  8. Jeff KingOct 19, 2012
  9. Junio C HamanoOct 19, 2012
  10. Junio C HamanoOct 19, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.