curl / Mailing Lists / curl-library / Single Mail

curl-library

Timeout with curl multi on connection refused on windows

From: Philippe Daouadi <philippe.daouadi_at_tanker.io>
Date: Thu, 16 Feb 2017 11:08:50 +0100

Hi,

I am using curl multi with a boost asio backend. On windows only, when I
open a connection that's supposed to be refused (my test connects to
http://127.0.0.1:1/), curl never signals me that the socket couldn't
connect.

I am not sure where the bug is, but I think it is in curl. From what I
saw in curl's code, curl does an asychronous connect() and sets a timer
(through the multi's timer callback) to 200ms. After those 200ms, curl
checks that the socket is indeed connected (CURLM_STATE_WAITCONNECT in
multi_runsingle() in multi.c), and for some reason windows doesn't
return the "connection refused" error yet. Then nothing more happens,
curl doesn't set a new timer to check the connection again. In the end,
the timeout set on the request (if there is one) triggers and we get a
connection timeout error.

If I pause through the debugger, or if I force the timer to wait for 1s
instead of 200ms, curl gets the connection refused error and everything
goes fine.

Shouldn't curl check another time the connection state after the first
200ms timeout? Or is the problem in my code? Getting a minimal example
from my code seems difficult, but if you need it I can try.

Cheers,
Philippe
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2017-02-16