aboutsummaryrefslogtreecommitdiff
path: root/lib/multi.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2013-06-03 20:19:51 +0200
committerDaniel Stenberg <daniel@haxx.se>2013-06-03 20:27:08 +0200
commit29bf0598aad58d9da5dd8c5358f5175dae49026d (patch)
tree40e4c8e13427be600c197375ae880a9127d40458 /lib/multi.c
parent239b58d34d323e8cf38b7be13a32dda188fec5d7 (diff)
curl_multi_wait: reduce timeout if the multi handle wants to
If the multi handle's pending timeout is less than what is passed into this function, it will now opt to use the shorter time anyway since it is a very good hint that the handle wants to process something in a shorter time than what otherwise would happen. curl_multi_wait.3 was updated accordingly to clarify This is the reason for bug #1224 Bug: http://curl.haxx.se/bug/view.cgi?id=1224 Reported-by: Andrii Moiseiev
Diffstat (limited to 'lib/multi.c')
-rw-r--r--lib/multi.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/multi.c b/lib/multi.c
index ef4038306..e4b336964 100644
--- a/lib/multi.c
+++ b/lib/multi.c
@@ -76,6 +76,8 @@ static bool isHandleAtHead(struct SessionHandle *handle,
static CURLMcode add_next_timeout(struct timeval now,
struct Curl_multi *multi,
struct SessionHandle *d);
+static CURLMcode multi_timeout(struct Curl_multi *multi,
+ long *timeout_ms);
#ifdef DEBUGBUILD
static const char * const statename[]={
@@ -810,10 +812,17 @@ CURLMcode curl_multi_wait(CURLM *multi_handle,
unsigned int nfds = 0;
unsigned int curlfds;
struct pollfd *ufds = NULL;
+ long timeout_internal;
if(!GOOD_MULTI_HANDLE(multi))
return CURLM_BAD_HANDLE;
+ /* If the internally desired timeout is actually shorter than requested from
+ the outside, then use the shorter time! */
+ (void)multi_timeout(multi, &timeout_internal);
+ if(timeout_internal < (long)timeout_ms)
+ timeout_ms = (int)timeout_internal;
+
/* Count up how many fds we have from the multi handle */
easy=multi->easy.next;
while(easy != &multi->easy) {