cURL / Mailing Lists / curl-library / Single Mail


Re: Timeout of 0 in url.c: SocketIsDead()

From: Daniel Stenberg <>
Date: Wed, 11 May 2011 22:44:06 +0200 (CEST)

On Wed, 11 May 2011, Eoin Fearghail wrote:

> But ultimately what I was wondering was whether there was a reason
> not to pass in a timeout to make sure the code always popped out of the
> loop.

Yes there is: the reason is simply that there should be no wait. The code
wants to know the status of the socket now and only now and if nothing exists
to read/write it should return that status.

> There may be a conflict in the same arg timeout_ms being passed to
> select to indicate no blocking, and the timeout used in the function itself
> where 0 means never timeout..

0 means no blocking/waiting in both the SocketIsDead() prototype and the
timeout passed to poll() or select(). It is not a conflict.

> What I saw was select returning -1, and SOCKERRNO returning 0,

This is the problem and if you can elaborate on what system you use and what
you do to make this happen then things will turn interesting!

I guess we can consider a modification like this to avoid such a loop:

--- a/lib/select.c
+++ b/lib/select.c
@@ -287,7 +287,7 @@ int Curl_socket_ready(curl_socket_t readfd, curl_socket_t
      if(r != -1)
      error = SOCKERRNO;
- if(error && error_not_EINTR)
+ if(!error || (error && error_not_EINTR))
      if(timeout_ms > 0) {
        pending_ms = timeout_ms - elapsed_ms;


List admin:
Received on 2011-05-11