[zeromq-dev] patch: non-blocking tcp accept

George Neill georgen at neillnet.com
Tue Apr 28 13:11:27 CEST 2009


Martin,

On Tue, Apr 28, 2009 at 5:53 AM, Martin Sustrik <sustrik at fastmq.com> wrote:
>
>>> The one thing I'm unsure of is EAGAIN/EWOULDBLOCK distinction. It seems
>>> that both Linux and Win32 assign the same numeric value to both errors.
>>> I am not sure of other platforms.
>>>
>>> POSIX says:
>>>
>>> [EAGAIN]
>>>    Resource unavailable, try again (may be the same value as
>>> [EWOULDBLOCK]).
>>>
>>> [EWOULDBLOCK]
>>>    Operation would block (may be the same value as [EAGAIN]).
>>>
>>> Pretty confusing...
>>
>> from /usr/include/errno.h on AIX 5.3 ...
>>
>> /* non-blocking and interrupt i/o */
>> /*
>>  * AIX returns EAGAIN where 4.3BSD used EWOULDBLOCK;
>>  * but, the standards insist on unique errno values for each errno.
>>  * A unique value is reserved for users that want to code case
>>  * statements for systems that return either EAGAIN or EWOULDBLOCK.
>>  */
>> #if _XOPEN_SOURCE_EXTENDED==1
>> #define EWOULDBLOCK     EAGAIN   /* Operation would block       */
>> #else /* _XOPEN_SOURCE_EXTENDED */
>> #define EWOULDBLOCK     54
>> #endif /* _XOPEN_SOURCE_EXTENDED */
>>
>> Might help de-confuse?
>
> Oh my. It's even worse then I've expected :) The actual values may change
> depending on macros defined.
>
> I've checked Solaris in the meantime - same value for both errors.
>
> Anyway, it seems that checking for both errors everywhere we are checking
> for one of the two at the moment would yield a sane result.

I believe that to be an acceptable solution (and common-place).

Quite possible to throw in some macro magic,

#if EAGAIN != EWOULDBLOCK
  // deal with possible EWOULDBLOCK
#endif

Later,
George



More information about the zeromq-dev mailing list