Strange EPOLLOUT|EPOLLET behaviour (spurious events)

From: Christof Meerwald
Date: Sun Apr 22 2012 - 11:41:24 EST


Hi,

I am seeing some unexpected behaviour with EPOLLOUT in edge-triggered
mode - some example code is available from
http://svn.cmeerw.net/src/nginetd/trunk/test/eptest-out.c

What seems to be happening is that I get an EPOLLOUT event after each
send on the socket (even in edge-triggered mode). This is what strace
shows me:

epoll_create(1024) = 3
socketpair(PF_FILE, SOCK_DGRAM, 0, [4, 5]) = 0
fcntl(5, F_GETFL) = 0x2 (flags O_RDWR)
fcntl(5, F_SETFL, O_RDWR|O_NONBLOCK) = 0
epoll_ctl(3, EPOLL_CTL_ADD, 5, {EPOLLIN|EPOLLOUT|EPOLLET, {u32=5, u64=5}}) = 0
sendto(5, "\0\0\0\0", 4, 0, NULL, 0) = 4
recvfrom(4, "\0\0\0\0", 4, 0, NULL, NULL) = 4
epoll_wait(3, {{EPOLLOUT, {u32=5, u64=5}}}, 16, 0) = 1
sendto(5, "\1\0\0\0", 4, 0, NULL, 0) = 4
recvfrom(4, "\1\0\0\0", 4, 0, NULL, NULL) = 4
epoll_wait(3, {{EPOLLOUT, {u32=5, u64=5}}}, 16, 0) = 1
sendto(5, "\2\0\0\0", 4, 0, NULL, 0) = 4
recvfrom(4, "\2\0\0\0", 4, 0, NULL, NULL) = 4
epoll_wait(3, {{EPOLLOUT, {u32=5, u64=5}}}, 16, 0) = 1

But as I am using EPOLLET, I wouldn't expect to get any EPOLLOUT
events on that socket as send never returns EAGAIN (and there isn't
any state transition).

BTW, I have seen https://lkml.org/lkml/2011/11/17/48 , but my case is
different (as there isn't any EPOLLIN event on that socket either).

Am I missing something here?


Christof

--

http://cmeerw.org sip:cmeerw at cmeerw.org
mailto:cmeerw at cmeerw.org xmpp:cmeerw at cmeerw.org
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/