[zeromq-dev] Epolling on FD doesn't work for 2.1.11

Andrzej K. Haczewski ahaczewski at gmail.com
Tue Mar 20 15:45:30 CET 2012

First of all I'd like to say hello to everyone, since this is my first
post here. So:


I've been trying to integrate ZeroMQ with libev event loop and I've
hit a strange behavior (or a bug?). In particular, as anyone
integrating with event loop, I've been watching (libev calls it like
that) my sockets for any input events, passing file descriptors taken
using getsockopt(ZMQ_FD).

How surprised I was that for REQ and REP sockets only REP socket
received notifications. Trying to isolate an error I simulated the
behavior using Python and epoll:

On my system (linux 3.1.6 amd64) and ZeroMQ 2.1.11 the output of that
code looks like this:
[(16, 1)]

Upgrading ZeroMQ to 3.1.0 the situation changes dramatically,
outputting what I expected:
[(9, 1), (10, 1)]
[(9, 1), (10, 1)]

Trying to get help on #zeromq I was told that it might be an issue
with level-triggering epoll, so I tried switching to edge-triggered
poll. Unfortunately it doesn't work for neither 2.1.11 nor 3.1.0.

Investigating further I got source code for both ZeroMQ 2.1 and 3.1and
found out that the FD returned from getsockopt(ZMQ_FD) comes from
zmq::signaler_t, which internal implementation changed between 2.1 and
3.1 for my kind of system from using simple socketpair in 2.1 to
eventfd in 3.1. That might be why 3.1 works and 2.1.11 does not.

Anyway, is it expected behavior or should I file a bug with ZeroMQ
2.1.11? Or maybe my code is wrong?

Thanks in advance for your help.

Andrzej Haczewski

More information about the zeromq-dev mailing list