1
0
mirror of https://github.com/moparisthebest/curl synced 2024-11-11 12:05:06 -05:00

multi: add timer inaccuracy margin to timeout/connecttimeout

Since all systems have inaccuracy in the timeout handling it is
imperative that we add an inaccuracy margin to the general timeout and
connecttimeout handling with the multi interface. This way, when the
timeout fires we should be fairly sure that it has passed the timeout
value and will be suitably detected.

For cases where the timeout fire before the actual timeout, we would
otherwise consume the timeout action and still not run the timeout code
since the condition wasn't met.

Reported-by: He Qin
Bug: http://curl.haxx.se/bug/view.cgi?id=1298
This commit is contained in:
Daniel Stenberg 2013-12-02 15:33:32 +01:00
parent 8e2d73bbde
commit be28223f35
2 changed files with 5 additions and 2 deletions

View File

@ -30,6 +30,8 @@
#define MULTI_TIMEOUT_INACCURACY 3000
#endif
#define MULTI_TIMEOUT_INACCURACY_MS (MULTI_TIMEOUT_INACCURACY / 1000)
/*
* Prototypes for library-wide functions provided by multi.c
*/

View File

@ -1309,10 +1309,11 @@ CURLcode Curl_pretransfer(struct SessionHandle *data)
Curl_pgrsStartNow(data);
if(data->set.timeout)
Curl_expire(data, data->set.timeout);
Curl_expire(data, data->set.timeout + MULTI_TIMEOUT_INACCURACY_MS);
if(data->set.connecttimeout)
Curl_expire(data, data->set.connecttimeout);
Curl_expire(data, data->set.connecttimeout +
MULTI_TIMEOUT_INACCURACY_MS);
/* In case the handle is re-used and an authentication method was picked
in the session we need to make sure we only use the one(s) we now