Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.development.apps > #472

Re: Strange EPOLLOUT|EPOLLET behaviour (spurious events)

From Rainer Weikusat <rweikusat@mssgmbh.com>
Newsgroups comp.os.linux.development.apps
Subject Re: Strange EPOLLOUT|EPOLLET behaviour (spurious events)
Date 2012-04-25 23:11 +0100
Message-ID <87ehrbmpg8.fsf@sapphire.mobileactivedefense.com> (permalink)
References <slrnjpgo5a.q7.cmeerw@msgid.cmeerw.org>

Show all headers | View raw


Christof Meerwald <NOSPAM-seeMySig+uyk5+@usenet.cmeerw.org> writes:
> 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:

[...]

> 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).

That's expected behaviour: You get EPOLLOUT as soon as 'a send
operation' completed. You will also get EPOLLIN whenever the state
transitions from 'buffer empty' to 'buffer not empty' irregardless of
read ever returning EAGAIN. The kernel doesn't keep track of which
state changes where communicated to a userspace application. If this
is a problem, you should initially have all notifications disabled and
only enable them after 'something failed with EAGAIN'. It is necessary
to be somewhat careful in this cases so that state transitions aren't
lost. In pseudo-code, the logic could look like this:

	1. perform operation
        2. EAGAIN? if not, goto done
        3. enable event
        4. perform operation again
        5. EAGAIN? if yes, goto 'wait for notification'
        6. disable event
        7. done

This may, of course, result in lots and lots of epoll_ctl calls ...

Back to comp.os.linux.development.apps | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Strange EPOLLOUT|EPOLLET behaviour (spurious events) Christof Meerwald <NOSPAM-seeMySig+uyk5+@usenet.cmeerw.org> - 2012-04-25 20:38 +0000
  Re: Strange EPOLLOUT|EPOLLET behaviour (spurious events) Rainer Weikusat <rweikusat@mssgmbh.com> - 2012-04-25 23:11 +0100
    Re: Strange EPOLLOUT|EPOLLET behaviour (spurious events) Christof Meerwald <NOSPAM-seeMySig+upk5+@usenet.cmeerw.org> - 2012-04-26 06:01 +0000
      Re: Strange EPOLLOUT|EPOLLET behaviour (spurious events) Rainer Weikusat <rweikusat@mssgmbh.com> - 2012-04-26 15:14 +0100
      Re: Strange EPOLLOUT|EPOLLET behaviour (spurious events) Christof Meerwald <NOSPAM-seeMySig+u0k5+@usenet.cmeerw.org> - 2012-04-26 21:11 +0000

csiph-web