Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'sz/maint-curl-multi-timeout'

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.
Detect this and reduce the wait timeout in such a case.

* sz/maint-curl-multi-timeout:
  Fix potential hang in https handshake
  • Loading branch information...
commit 23a50a1fb113b702012935ee8c6e945cf58edbd7 2 parents d9253f2 + 7202b81
Jeff King peff authored

Showing 1 changed file with 12 additions and 0 deletions. Show diff stats Hide diff stats

  1. +12 0 http.c
12 http.c
@@ -631,6 +631,18 @@ void run_active_slot(struct active_request_slot *slot)
631 631 FD_ZERO(&excfds);
632 632 curl_multi_fdset(curlm, &readfds, &writefds, &excfds, &max_fd);
633 633
  634 + /*
  635 + * It can happen that curl_multi_timeout returns a pathologically
  636 + * long timeout when curl_multi_fdset returns no file descriptors
  637 + * to read. See commit message for more details.
  638 + */
  639 + if (max_fd < 0 &&
  640 + (select_timeout.tv_sec > 0 ||
  641 + select_timeout.tv_usec > 50000)) {
  642 + select_timeout.tv_sec = 0;
  643 + select_timeout.tv_usec = 50000;
  644 + }
  645 +
634 646 select(max_fd+1, &readfds, &writefds, &excfds, &select_timeout);
635 647 }
636 648 }

0 comments on commit 23a50a1

Please sign in to comment.
Something went wrong with that request. Please try again.