curl-library
Re: libcurl + libevent2: Stalling if no data is received/written [timeout bug patch]
Date: Mon, 23 Aug 2010 16:17:24 +0200
On Sunday 22 August 2010 23:21:10 Daniel Stenberg wrote:
> Right, the dreaded bug #62 was still present in 7.21.1 and was actually just
> fixed in git.
Duh! Looks like there's still a time-out bug with the multi interface.
I've played again with the examples multi-single.c and hiperfifo.c,
after adding CURLOPT_TIMEOUT both example programs detects time-out
while connecting. But after connection only multi-single.c (using
curl_multi_timeout) will detect a time-out, but not hiperfifo.c
(using timer callback).
I think the bug is in function multi_runsingle within case CURLM_STATE_PERFORM,
there are upload/download speed checks but no check of the elapsed time.
So I've added such a check at the end of that case block, but maybe it's
better placed at the beginning of that block....
diff --git a/lib/multi.c b/lib/multi.c
index dd196b7..14c2050 100644
--- a/lib/multi.c
+++ b/lib/multi.c
@@ -1505,6 +1505,14 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
}
}
+ /* not finshed yet, check timeout */
+ if(data->set.timeout) {
+ k->now = Curl_tvnow();
+ long timeout_ms = data->set.timeout - Curl_tvdiff(k->now, k->start);
+ if(timeout_ms > 0)
+ Curl_expire(data, timeout_ms);
+ /* TODO: throw time-out error here if it's already expired? */
+ }
break;
case CURLM_STATE_DONE:
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-08-23