From 3880dd3741204965dde312643a18190a24c66ba9 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 17 Sep 2010 22:58:08 +0200 Subject: Curl_timeleft: avoid returning "no timeout" by mistake As this function uses return code 0 to mean that there is no timeout, it needs to check that it doesn't return a time left value that is exactly zero. It could lead to libcurl doing an extra 1000 ms select() call and thus not timing out as accurately as it should. I fell over this bug when working on the bug 3061535 but this fix does not correct that problem alone, although this is a problem that needs to be fixed. Reported by: Rodric Glaser Bug: http://curl.haxx.se/bug/view.cgi?id=3061535 --- lib/connect.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib') diff --git a/lib/connect.c b/lib/connect.c index e440913e9..e178633d8 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -174,6 +174,9 @@ long Curl_timeleft(struct connectdata *conn, /* substract elapsed time */ timeout_ms -= Curl_tvdiff(*nowp, data->progress.t_startsingle); + if(!timeout_ms) + /* avoid returning 0 as that means no timeout! */ + return -1; return timeout_ms; } -- cgit v1.2.3