So after a lot of work (and a lot of help from both Chuck Remes and Evan
Phoenix), I tracked down that weird bug I posted to the ML earlier regarding
nbytes != -1 and EBADF.

It boils down to calling zmq_getsockopt(ZMQ_FD) and then a third party
library assuming it could shutdown() and close() the FD. Since the FD that
is returned is an internal ZMQ socketpair, this is a bad thing, and causes
zmq to go haywire, because reading from it causes an EBADF.

My proposal is to check for EBADF somewhere in zmq::mailbox_t::recv and
print out a nice message like "Internal socketpair closed, maybe you tried
closing a ZMQ FD? Please don't do that"

I think once ZMQ_FDs get released, others will definitely get this same
error, which can be very difficult to track down.

I encountered it because ruby's eventmachine library attempts to clean up
FDs when it hits a fatal exception, by calling close(), and shutdown() on
them. Others integrating ZMQ_FDs into existing reactor libraries will likely
hit this same bug, which, while not ZMQ's fault, could give a much more
helpful error.
_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to