[zeromq-dev] Strange behavior of file-descriptor read event notification

Victor Lin bornstub at gmail.com
Fri Jan 20 19:08:46 CET 2012


Hi,

I'm investigating a bug of txZMQ:

https://github.com/smira/txZMQ/pull/3

I notice that's it is caused by the file descriptor is not notified for
read event, if the send operation is complete before selecting. I write a
simple program to reproduce it.

http://pastie.org/3220179

The output of not waiting send operation:

    $ python poll.py 0
    id sherlock
    fd 17
    Do not wait the send
    The fd will be notified if we do not wait for send
    # echo ['test']
    # events 2
    !!! FD is notified
    # events 3
    ??? FD is not notified
    # events 3
    ??? FD is not notified
    # events 3
    ??? FD is not notified

The output for waiting for send operation:

    $ python poll.py 1
    id sherlock
    fd 17
    Wait send op complete
    Oddly, if the send is complete, then the fd will not be notified
    # echo ['test']
    # events 3
    ??? FD is not notified
    # events 3
    ??? FD is not notified
    # events 3
    ??? FD is not notified

I can fix this bug by checking event and doing read after every send in
txZMQ, but to make sure, I would like to know is this a bug or feature? As
my understanding, I think if it is a feature, when the send operation
complete, it notifies fd for a read event, but then set POLLIN event of
socket and clean the read event in fd. So, if send operation complete
before selecting, the select have no chance to catch the fd event (should
check socket event first). If the send operation is complete after
selecting, then we can catch the read event of fd. Is my understanding
correct? Sorry I'm newbie for ZeroMQ. Is there any document that mention
this kind of behavior? Or which part of source code should I read?

Thanks.
Victor Lin.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20120121/e38f096b/attachment.htm>


More information about the zeromq-dev mailing list