Search code examples
linuxsocketsepollepollet

epoll - is EPOLLET prone to race conditions?


  1. Process B epolls on the pipe (EPOLLIN|EPOLLET).
  2. Process A writes 1KiB in pipe.
  3. Process B wakes up.
  4. Process B reads 1KiB from the pipe.
  5. Process A writes 1KiB in pipe.
  6. Process B epolls on the pipe.

The state of the pipe does not change during epoll, but has changed since the last read. Will process B wake up again?


Solution

  • My understanding from the FAQ (Q9) in http://linux.die.net/man/4/epoll is that you will get another event in step 6 (assuming that you can guarantee that step 5 really happens after step 4 and the pipe is empty after step 4).

    Having said that, you might get more events than guaranteed (but you have to be careful only to rely on documented behavior) - see http://cmeerw.org/blog/753.html#753 and http://cmeerw.org/blog/750.html#750