cURL / Mailing Lists / curl-library / Single Mail

curl-library

AllowServerConnect timing

From: Yang Tse <yangsita_at_gmail.com>
Date: Sun, 22 Apr 2007 03:17:12 +0200

Some more gettimeofday() strange usage hunting has taken me up to
AllowServerConnect() in ftp.c

As it is right now, the timeout allowed for the server to connect back
that will be used is CURLOPT_CONNECTTIMEOUT, CURLOPT_TIMEOUT or 60
seconds whichever is set in that order.

There is also a small amount that is subtracted from the timeout
called 'timespent'. This will be a value near zero as it is calculated
in two consecutive lines as;

struct timeval now = Curl_tvnow();
long timespent = Curl_tvdiff(Curl_tvnow(), now);

It think it doesn't make much sense to have this in this way. But
several options arise.

1) Remove the current near-zero timespent value and calculation
avoiding two gettimeofday() calls.

2) Calculate timespent as the difference between actual time and the
time the last response time-out was set. This saves one gettimeofday()
call.

long timespent = Curl_tvdiff(Curl_tvnow(), conn->proto.ftpc->response);

3) Other, none of the above.

Comments?

-- 
-=[Yang]=-
Received on 2007-04-22