curl-library
Re: CURL_ACKNOWLEDGE_EINTR
Date: Thu, 18 Aug 2011 02:56:16 +0200
Bllllllluuuuuuuuuussssssssssssssshhhhhhhhhhhhhhhhhhhh
I'll quote my self to amend my badness...
> When CURL_ACKNOWLEDGE_EINTR is defined, what is left is code that
> loops if select fails and errno is not zero.
This first sentence quoted above is wrong and fully misleading. Where
it says "and errno is not zero" should read "and errno _is_ zero".
> In the default case, when CURL_ACKNOWLEDGE_EINTR is not defined, What
> is left is code that loops if select returns an error and errno is not
> zero and errno is not EINTR.
This second sentence is correct, and additionally the code does what
it is intended to do.
I'll try to straight things here...
When CURL_ACKNOWLEDGE_EINTR is not defined, default setting, the
actual loop is...
| do {
| r = select([...], &pending_tv);
| if(r != -1)
| break;
| error = SOCKERRNO;
| if(error && (error != EINTR))
| break;
| pending_ms = timeout_ms - elapsed_ms;
| if(pending_ms <= 0)
| break;
| } while(r == -1);
This will loop, while tiemout is not consumed, allways that (select
fails) and (errno is not zero) and (errno is not EINTR). IOW results
in a select loop in which EINTR signal is ignored but other errno
conditions exit the loop right away.
When CURL_ACKNOWLEDGE_EINTR is defined, opt in setting, the actual loop is...
| do {
| r = select(...);
| if(r != -1)
| break;
| error = SOCKERRNO;
| if(error && (1))
| break;
| pending_ms = timeout_ms - elapsed_ms;
| if(pending_ms <= 0)
| break;
| } while(r == -1);
This will loop, while tiemout is not consumed, allways that (select
fails) and (errno is zero). IOW results in a select loop in which any
errno condition exits the loop right away.
All this works nicely as long as all three of the following points stand true:
1) A failed select() call returns -1.
2) A failed select() call sets errno appropiately to not zero.
3) EINTR is defined to the value that errno is set when select() fails.
Which is in conformance with
http://pubs.opengroup.org/onlinepubs/7908799/xsh/select.html
-- -=[Yang]=- ------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.htmlReceived on 2011-08-18