- Michael Wallner provided a patch that adds support for CURLOPT_TIMEOUT_MS
and CURLOPT_CONNECTTIMEOUT_MS that, as their names should hint, do the timeouts with millisecond resolution instead. The only restriction to that is the alarm() (sometimes) used to abort name resolves as that uses full seconds. I fixed the FTP response timeout part of the patch. Internally we now count and keep the timeouts in milliseconds but it also means we multiply set timeouts with 1000. The effect of this is that no timeout can be set to more than 2^31 milliseconds (on 32 bit systems), which equals 24.86 days. We probably couldn't before either since the code did *1000 on the timeout values on several places already.
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@@ -558,15 +558,15 @@ CURLcode Curl_is_connected(struct connectdata *conn,
|
||||
/* subtract the most strict timeout of the ones */
|
||||
if(data->set.timeout && data->set.connecttimeout) {
|
||||
if (data->set.timeout < data->set.connecttimeout)
|
||||
allow_total = allow = data->set.timeout*1000;
|
||||
allow_total = allow = data->set.timeout;
|
||||
else
|
||||
allow = data->set.connecttimeout*1000;
|
||||
allow = data->set.connecttimeout;
|
||||
}
|
||||
else if(data->set.timeout) {
|
||||
allow_total = allow = data->set.timeout*1000;
|
||||
allow_total = allow = data->set.timeout;
|
||||
}
|
||||
else if(data->set.connecttimeout) {
|
||||
allow = data->set.connecttimeout*1000;
|
||||
allow = data->set.connecttimeout;
|
||||
}
|
||||
|
||||
if(has_passed > allow ) {
|
||||
@@ -826,14 +826,14 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
|
||||
/* get the most strict timeout of the ones converted to milliseconds */
|
||||
if(data->set.timeout && data->set.connecttimeout) {
|
||||
if (data->set.timeout < data->set.connecttimeout)
|
||||
timeout_ms = data->set.timeout*1000;
|
||||
timeout_ms = data->set.timeout;
|
||||
else
|
||||
timeout_ms = data->set.connecttimeout*1000;
|
||||
timeout_ms = data->set.connecttimeout;
|
||||
}
|
||||
else if(data->set.timeout)
|
||||
timeout_ms = data->set.timeout*1000;
|
||||
timeout_ms = data->set.timeout;
|
||||
else
|
||||
timeout_ms = data->set.connecttimeout*1000;
|
||||
timeout_ms = data->set.connecttimeout;
|
||||
|
||||
/* subtract the passed time */
|
||||
timeout_ms -= has_passed;
|
||||
|
Reference in New Issue
Block a user