Fwd: libev doesn't notify on read event (file FD and timers)

Assaf Inbal shmuelzon at gmail.com
Thu Apr 24 10:30:09 CEST 2014


Hey all,

I'm using libev as a part of a larger project. In this project I have a
library that does some asynchronous work directly over FDs and timers.
While I understand that it's not exactly recommended, these FDs can also be
of local files as well as sockets.

As a part of the process, I have an EV_READ event set on a file, in that
handler I stop the event handler and close the FD. I then set a timer and
in that timer, open another file and set a read event on it.
The issue is that the read event on the second file is never called.
I've attached a sample code file to show this happening.
I'm using libev 4.11 on Ubuntu 12.04 LTS compiling with gcc as follows: gcc
ev_test.c -o ev_test -lev
I also tried to locally compile 4.15 but the issue reproduced there as well
(assuming I did so correctly).

It's worth mentioning that if I disable the timer and create the second
read event in the first's handler (undef USE_TIMER) everything works as
expected.
I also tried not closing the FD (commenting out line 36), thus making the
second file get a different FD, and that also worked.
Changing the timeout value from 0 to anything else didn't help.

Can anyone please tell me why this happens? Or, better yet, how I can fix
it?

Thanks,
Assaf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schmorp.de/pipermail/libev/attachments/20140424/e5238970/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ev_test.c
Type: text/x-csrc
Size: 1227 bytes
Desc: not available
URL: <http://lists.schmorp.de/pipermail/libev/attachments/20140424/e5238970/attachment.c>


More information about the libev mailing list