epoll spurious events example code for libev 3.41

common at gmx.ch common at gmx.ch
Sun Mar 8 23:21:27 CET 2009


Hi,

as I've had an old version of libev (3.41) on a different machine, I ran
into the epoll spurious event notification bug.
I noticed the libev version to late and wrote example code to
reproduce the problem.
I guess it could be usefull for the epoll developers.

Basically,
  * accept a connection A
    * set A nonblocking
  * recv something on A
    * fork,
    * in child run system() or execv
  * close A
  * accept a new connection B which gets the same fd as A had previously

leads to an endless loop with the read callback for B getting called all
time, even though there is no data to read.

Attached is a small programm which triggers the bug here on a linux
2.6.27 x86_64 smp machine.

Compile using
gcc -Wall -L/opt/libev/lib/libev/ -I/opt/libev/include spurious.c -o
spurious -lev

run it
./spurious

in a different terminal

nc localhost 4711

> send a character to fork a process
> disconnect netcat

nc localhost 4711
> triggers the bug

the sample program will loop with something like

read_connection loop 0x7fad4968a1c0 ev_io 0x18b2650 revents 1 (fd 6)
	 EAGAIN


Works fine using libev 3.53.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: spurious.c
Type: text/x-csrc
Size: 2793 bytes
Desc: not available
URL: <http://lists.schmorp.de/pipermail/libev/attachments/20090308/f48895fe/attachment.c>


More information about the libev mailing list