[zeromq-dev] Returning EINTR on interrupted non-blocking calls

Steven McCoy steven.mccoy at miru.hk
Wed Nov 18 14:25:57 CET 2009


2009/11/18 Martin Sustrik <sustrik at 250bpm.com>

> I've implemented the EINTR thing, however, it turns out that it won't be
> of much help in multithreaded environment - the signal is delivered to a
> single thread, leaving other threads blocked in the blocking call :(
>
>
 I've seen a lot of the problems handling blocking sockets in OpenPGM that I
default to using non-blocking sockets internal and provide an option to
present either blocking or non-blocking operation on the interface.

You should always leave signal handling to the application, you might want
to consider provided equivalent functionality to handling interrupt signals
though, e.g. WSACancelBlockingCall in WinSock 1, or a close method that
causes all blocking operations to immediately cancel.

http://msdn.microsoft.com/en-us/library/ms741547(VS.85).aspx

I made the mistake of misinterpreting this detail in the recv manpage that
now states "The return value will be 0 when the peer  has  performed
 an orderly shutdown." to being that you could close a blocking socket and
it would return 0.  So that was wrong and I'm not aware that there is any
reliable method to break a blocking socket?

-- 
Steve-o
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20091118/a5f34ac6/attachment.htm>


More information about the zeromq-dev mailing list