cURL / Mailing Lists / curl-library / Single Mail

curl-library

Socket readable before curl_socket_callback?

From: Raf Nulens <raf.nulens_at_androme.com>
Date: Mon, 10 Mar 2008 16:17:43 +0100

Dear all,

Sometimes we dont get a read/write event after setting a read/write flag
  on a socket (using winsock2).

We are performing a POST operation, so first we perform a DNS lookup
(we're using libcurl built with ares):

"curl_multi_socket_all: " // start perform multi_socket_all (1)
"curl_multi_socket_all: code=-1 CURLM_CALL_MULTI_PERFORM, descr=please
call curl_multi_perform() soon, count=1" // ended perform
multi_socket_all (1)
"curl_multi_socket_all: " // start perform multi_socket_all (2)
"curl_socket_callback: fd=2796, index=0, event=1"

** we set the read flag on socket 2796

"curl_multi_timer_callback: timeout=4813"
"curl_multi_socket_all: code=0 CURLM_OK, descr=no error, count=1" // end
perform multi_socket_all (2)

** we receive a notifyconnect from socket 2796

"curl_multi_socket: " // start perform multi socket (1)
"curl_multi_socket: fd=2796, code=0 CURLM_OK, descr=no error, count=1"
"curl_multi_socket: done, code = 0" // end perform multi socket (1)

** we receive a notifyread from socket 2796 (dns has been resolved)

"curl_multi_socket: " // start perform multi socket (2)
"curl_debug_callback: [text] [About to connect() to [some server] port
443 (#0)]"
"curl_debug_callback: [text] [ Trying [resolved IP address]... ]"
"curl_socket_callback: fd=2792, index=0, event=2"

** we set the write flag for socket 2792

"curl_socket_callback: fd=2796, index=1, event=4"

** we remove socket 2796

"curl_multi_timer_callback: timeout=14798" // set the timeout
"curl_multi_socket: fd=2796, code=0 CURLM_OK, descr=no error, count=1"
"curl_multi_socket: done, code = 0" // end perform multi socket (2)

now we dont get a write event, but instead we get a timeout after 15
seconds. The connection itself has been set up, but already timed out
after those 15 seconds wait.

When we get a socket_callback is it possible that the socket in question
is already connected and write enabled so that we dont get a write
event? We suspect that when we set the write flag for socket 2792 in
the curl_socket_callback, we are too late to receive the event. Could
this be possible?

Kind regards,

Raf Nulens
Received on 2008-03-10