cURL / Mailing Lists / curl-library / Single Mail

curl-library

long timeout after a lost connection (curl 7.39, windows)

From: чи дер <chider_at_bk.ru>
Date: Thu, 11 Dec 2014 14:06:13 +0300

 Hi,

 I've come across the following curl problem, which can be easily reproduced on Windows (XP SP3 to be precise):

 1. connect to a remote host
 2. POST some data
 3. unplug the network cable (sometimes this happens when the server closes connection due to keep-alive settings, but unplugging is the most reliable)
 4. try POSTing another chunk of data and observe the following message:

"
* Found bundle for host XXX: 0x280e400
* Re-using existing connection! (#0) with host XXX
* Connected to XXX (XXX) port 8080 (#0)
> POST YYY HTTP/1.1
Host: XXX:8080
Accept: */*
Cookie: runmode=test
Content-Type: text/xml; charset="utf-8"
Content-Length: 940
* upload completely sent off: 940 out of 940 bytes
" This then stalls for minutes sometimes, while CURLOPT_TIMEOUT_MS and CURLOPT_CONNECTTIMEOUT_MS are set to 1 second. Such short timeout is critical in this specific application I'm working on.

If I break in the debugger it's sitting in:

Curl_poll(pollfd * ufds=0x02d1c6a0, unsigned int nfds=1, int timeout_ms=1000) Line 516 + 0x4f bytes C
curl_multi_wait(void * multi_handle=0x02851b18, curl_waitfd * extra_fds=0x00000000, unsigned int extra_nfds=0, int timeout_ms=1000, int * ret=0x0305f500) Line 890 + 0x11 bytes C
easy_transfer(void * multi=0x02851b18) Line 684 + 0x16 bytes C
easy_perform(SessionHandle * data=0x02cd9018, bool events=bool_false) Line 800 + 0x18 bytes C
curl_easy_perform(void * easy=0x02cd9018) Line 819 + 0xb bytes C specifically in :

r = select((int)maxfd + 1,
#ifndef USE_WINSOCK
&fds_read, &fds_write, &fds_err,
#else
/* WinSock select() can't handle fd_sets with zero bits set, so
don't give it such arguments. See the comment about this in
Curl_check_socket().
*/
fds_read.fd_count ? &fds_read : NULL,
fds_write.fd_count ? &fds_write : NULL,
fds_err.fd_count ? &fds_err : NULL,
#endif
ptimeout);
Where only fds_read is set to 1 and has the original socket handle.
I understand this is a windows-specific problem and I was wondering if there's a way to resolve this maybe by changing some parameters of the socket when it is created?

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-12-11