public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: epoll reporting events when it hasn't been asked to
@ 2004-04-01 18:25 Ben Mansell
  2004-04-01 19:28 ` Davide Libenzi
  0 siblings, 1 reply; 21+ messages in thread
From: Ben Mansell @ 2004-04-01 18:25 UTC (permalink / raw)
  To: linux-kernel

> It is a feature. epoll OR user events with POLLHUP|POLLERR so that even if
> the user sets the event mask to zero, it can still know when something
> like those abnormal condition happened. Which problem do you see with this?

What should the application do if it gets events that it didn't ask for?
If you choose to ignore them, the next time epoll_wait() is called it
will return instantly with these same messages, so the app will spin and
eat CPU.

The alternative is to put some kind of sanity-check wrapper around
epoll_wait() calls, and match the output with what the app asked for.
If epoll starts returning messages that it doesn't want, the only
alternative is to get heavy-handed and try to get epoll to shut up with
EPOLL_CTL_DEL on the file descriptor. But this seems like fighting
against the OS.

Perhaps it should only OR the user event with POLLHUP|POLLERR if
POLLIN or POLLOUT is set?


Ben


^ permalink raw reply	[flat|nested] 21+ messages in thread
* epoll reporting events when it hasn't been asked to
@ 2004-04-01 16:54 Ben
  2004-04-01 17:51 ` Davide Libenzi
  0 siblings, 1 reply; 21+ messages in thread
From: Ben @ 2004-04-01 16:54 UTC (permalink / raw)
  To: linux-kernel

Hi,

epoll seems to behave oddly with TCP sockets that return ECONNRESET on a
read. Here's an abridged strace snippet:
(my strace doesn't cope very well with epoll syscalls, so I've mixed in
 some of the program's debug output as well)

epoll_create(0x400)                     = 5

...

socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 10
setsockopt(10, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
setsockopt(10, SOL_SOCKET, SO_KEEPALIVE, [1], 4) = 0
bind(10, {sa_family=AF_INET, sin_port=htons(2342), sin_addr=inet_addr("10.100.1.208")}, 16) = 0

         EPollMultiplexer::Add( fd 10 events 1 )
epoll_ctl(0x5, 0x1, 0xa, 0xbffff010)    = 0

         EPollMultiplexer::Poll()
epoll_wait(0x5, 0x831b390, 0x20, 0x3e8) = 1
fd 10 has events 1

accept(10, {sa_family=AF_INET, sin_port=htons(47255), sin_addr=inet_addr("10.100.1.208")}, [16]) = 7

         EPollMultiplexer::Add( fd 7 events 1 )
epoll_ctl(0x5, 0x1, 0x7, 0xbffff5c0)    = 0

socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 11
connect(11, {sa_family=AF_INET, sin_port=htons(21), sin_addr=inet_addr("10.100.1.5")}, 16) = -1 EINPROGRESS (Operation now in progress)

         EPollMultiplexer::Add( fd 11 events 1 )
epoll_ctl(0x5, 0x1, 0xb, 0xbffff3f0)    = 0

         EPollMultiplexer::Poll()
epoll_wait(0x5, 0x831b390, 0x20, 0x3e8) = 1
fd 11 has events 1

         EPollMultiplexer::Poll()
epoll_wait(0x5, 0x831b390, 0x20, 0x3e8) = 2
fd 10 has events 1
fd 7 has events 25

read(7, 0x8336240, 4096)                = -1 ECONNRESET (Connection reset by peer)

         EPollMultiplexer::Poll()
         Setting events on fd 7 to 0
epoll_ctl(0x5, 0x3, 0x7, 0x8301550)     = 0
epoll_wait(0x5, 0x831b390, 0x20, 0x3e8) = 2
fd 11 has events 1
fd 7 has events 16


This is odd. The epoll_ctl() got rid of all events for FD 7, yet the
epoll_wait() following it returns event 16 (EPOLLHUP). Is this a bug?
I don't normally see this behaviour for most connections, is it perhaps
to do with the read returning ECONNRESET ?

(This is on 2.6.2-rc1-mm1 and on 2.6.5-rc3-mm3, on x86 and x86_64)


Ben

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2004-04-14 21:48 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-01 18:25 epoll reporting events when it hasn't been asked to Ben Mansell
2004-04-01 19:28 ` Davide Libenzi
2004-04-01 23:29   ` Steven Dake
2004-04-02  9:04     ` Ben Mansell
2004-04-02 15:22       ` Davide Libenzi
2004-04-02 18:40         ` Is POLLHUP an input-only or bidirectional condition? (was: epoll reporting events when it hasn't been asked to) Jamie Lokier
2004-04-03 12:19           ` Is POLLHUP an input-only or bidirectional condition? Richard Kettlewell
2004-04-03 21:44           ` Is POLLHUP an input-only or bidirectional condition? (was: epoll reporting events when it hasn't been asked to) Davide Libenzi
2004-04-03 22:35             ` Jamie Lokier
2004-04-04  1:28               ` Davide Libenzi
2004-04-04  2:08                 ` Jamie Lokier
2004-04-04  2:49                   ` Davide Libenzi
2004-04-04 18:51               ` Ben Mansell
2004-04-04 19:41                 ` Davide Libenzi
2004-04-04 20:24                 ` Jamie Lokier
2004-04-14 17:59         ` epoll reporting events when it hasn't been asked to Dirk Morris
2004-04-14 19:39           ` Jamie Lokier
2004-04-14 20:21             ` Dirk Morris
2004-04-14 21:48               ` Jamie Lokier
  -- strict thread matches above, loose matches on Subject: below --
2004-04-01 16:54 Ben
2004-04-01 17:51 ` Davide Libenzi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox