cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: [PATCH] timeout in ms

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Tue, 30 Jan 2007 21:40:06 -0800

On Tue, Jan 30, 2007 at 10:45:58AM +0100, Michael Wallner wrote:
> attached is a patch against current CVS, which is supposed to add timeout
> support in milliseconds (CURLOPT_TIMEOUT_MS, CURLOPT_CONNECTTIMEOUT_MS).
>
> AFAICT, there are three issues left:
> - SIGALRM, alarm() accepts seconds only
> - CONNECT, I lowered the timeout to 10ms
[...]
> /* if timeout is requested, find out how much remaining time we have */
> long check = timeout - /* timeout time */
> - Curl_tvdiff(Curl_tvnow(), conn->now)/1000; /* spent time */
> + Curl_tvdiff(Curl_tvnow(), conn->now); /* spent time */
> if(check <=0 ) {
> failf(data, "Proxy CONNECT aborted due to timeout");
> error = SELECT_TIMEOUT; /* already too little time */
> break;
> }
>
> - /* timeout each second and check the timeout */
> - switch (Curl_select(tunnelsocket, CURL_SOCKET_BAD, 1000)) {
> + /* timeout each 10 milliseconds and check the timeout, FIXME: reasonable resolution? */
> + switch (Curl_select(tunnelsocket, CURL_SOCKET_BAD, 10)) {
> case -1: /* select() error, stop reading */
> error = SELECT_ERROR;
> failf(data, "Proxy CONNECT aborted due to select() error");

Reducing the timeout to 10 ms here turns this practically into a busy loop,
checking 100 times a second, which could be significant on slower platforms.
Why can't the timeout value here be set to the value of 'check' and
avoid the tight loop altogether?

>>> Dan

-- 
http://www.MoveAnnouncer.com              The web change of address service
          Let webmasters know that your web site has moved
Received on 2007-01-31