cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: libcurl + libevent2: Stalling if no data is received/written [new timeout patch]

From: Dirk Manske <dm_at_nonitor.de>
Date: Thu, 2 Sep 2010 12:09:30 +0200

On Wednesday 01 September 2010 17:45:58 Daniel Stenberg wrote:
> I've committed a few more related fixes this afternoon.
>
> Before I pushed my changes, I tested my code with hiperfifo both using c-ares
> and the threaded resolver. I had the server just be 'nc -l -p9999' with a
> connect and total timeout for each handle and they seemed to timeout as asked
> for.
>
> It'd be great if you can update and run some tests again and see how it seems
> to behave for you now.

Using curl-git with threaded resolver or c-ares and multi-single connect
timeout and total timeout are handled nicely. But compared to curl-stable
I'm missing some verbose output:

Reported by curl-7.21.1 and not 7.21.2-DEV:

connection timeout:

* Connection time-out
* Expire cleared
* Closing connection #0
res:28 os:0 rc:0 errrmsg:Connection time-out

timeout after connect:

* Operation timed out after 7008 milliseconds with 0 bytes received
* Closing connection #0
res:28 os:0 rc:0 errrmsg:Operation timed out after 7008 milliseconds with 0 bytes received

After I found that the "* " lines are missing, I've added

 char errmsg[CURL_ERROR_SIZE];
 errmsg[0] = '\0';
 curl_easy_setopt(http_handle, CURLOPT_ERRORBUFFER, errmsg);

to multi-single.c to grab the error message. With curl-git
these error messages are not set:

res:28 os:0 rc:0 errrmsg:

I guess the connection cleanup code is skipped.

With hiperfifo it's the same... but with a new side effect:

Don't start 'nc -l -p 9999' yet, but ./hiperfifo
and do 'echo http://127.0.0.1:9999/ >hiper.fifo'

1283421299.717532 Adding easy 0x176a468 to multi 0x173dc98 (http://127.0.0.1:9999/)
1283421299.717582 multi_timer_cb: Setting timeout to 1 ms
1283421299.720849 timer_cb called fd:-1 kind:1
* About to connect() to 127.0.0.1 port 9999 (#0)
* Trying 127.0.0.1... * Connection refused
* couldn't connect to host
* Expire cleared
* Closing connection #0
1283421299.721137 multi_timer_cb: Setting timeout to -1 ms
1283421299.721141 timer_cb curl_multi_socket_action rc:0 running:0
1283421299.721145 timer_cb called fd:-1 kind:1
1283421299.721148 timer_cb curl_multi_socket_action rc:0 running:0

Alright, connection refused, but where is the DONE message from
hiperfifo... now start 'nc -l -p 9999' and do 'echo http://127.0.0.1:9999/ >hiper.fifo'

1283421439.269287 multi_timer_cb: Setting timeout to 4000 ms
1283421439.269301 timer_cb curl_multi_socket_action rc:0 running:1
1283421443.268828 timer_cb called fd:-1 kind:1
1283421443.268887 multi_timer_cb: Setting timeout to 3000 ms
1283421443.268902 timer_cb curl_multi_socket_action rc:0 running:1
1283421446.272824 timer_cb called fd:-1 kind:1
* STATE: PERFORM => COMPLETED handle 0x17a1a88; (connection #-5000)
* STATE: COMPLETED => MSGSENT handle 0x17a1a88; (connection #-5000)
1283421446.272902 socket callback: s=7 e=0x17a1b88 what=REMOVE
1283421446.272940 multi_timer_cb: Setting timeout to -1 ms
1283421446.272954 timer_cb curl_multi_socket_action rc:0 running:0
1283421446.272966 REMAINING: 0
1283421446.272982 DONE: http://127.0.0.1:9999/ => (7) msg:couldn't connect to host
1283421446.273179 DONE: http://127.0.0.1:9999/ => (28) msg:
* Connection #0 to host 127.0.0.1 left intact
1283421446.273319 timer_cb called fd:-1 kind:1
1283421446.273332 timer_cb curl_multi_socket_action rc:0 running:0

Oh, there is the missing DONE. ;-)
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-09-02