diff options
author | Daniel Stenberg <daniel@haxx.se> | 2007-02-05 22:51:32 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2007-02-05 22:51:32 +0000 |
commit | 91386937ff120d11f7bf24dc487f00751362a61c (patch) | |
tree | 9affbbce6d62c6082ef11430b84f6c6eaa071de7 /lib/url.c | |
parent | 0fc51ac5a6e9cca55398cabfafd4effdb3df21fe (diff) |
- 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.
Diffstat (limited to 'lib/url.c')
-rw-r--r-- | lib/url.c | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -734,7 +734,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, * An FTP option that specifies how quickly an FTP response must be * obtained before it is considered failure. */ - data->set.ftp_response_timeout = va_arg( param , long ); + data->set.ftp_response_timeout = va_arg( param , long ) * 1000; break; case CURLOPT_FTPLISTONLY: /* @@ -1242,12 +1242,21 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, * The maximum time you allow curl to use for a single transfer * operation. */ + data->set.timeout = va_arg(param, long) * 1000L; + break; + + case CURLOPT_TIMEOUT_MS: data->set.timeout = va_arg(param, long); break; + case CURLOPT_CONNECTTIMEOUT: /* * The maximum time you allow curl to use to connect. */ + data->set.connecttimeout = va_arg(param, long) * 1000L; + break; + + case CURLOPT_CONNECTTIMEOUT_MS: data->set.connecttimeout = va_arg(param, long); break; @@ -3828,9 +3837,14 @@ else { /* if timeout is not set, use the connect timeout */ shortest = data->set.connecttimeout; + if(shortest < 1000) + /* the alarm() function only provide integer second resolution, so if + we want to wait less than one second we must bail out already now. */ + return CURLE_OPERATION_TIMEDOUT; + /* alarm() makes a signal get sent when the timeout fires off, and that will abort system calls */ - prev_alarm = alarm((unsigned int) shortest); + prev_alarm = alarm((unsigned int) (shortest ? shortest/1000L : shortest)); /* We can expect the conn->created time to be "now", as that was just recently set in the beginning of this function and nothing slow has been done since then until now. */ |