lkml.org 
[lkml]   [2008]   [Oct]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: unexpected extra pollout events from epoll
On Sun, 26 Oct 2008, Paul P wrote:

> > You do that by writing data until it's finished, or you
> > get EAGAIN. If you
> > get EAGAIN, you listen for EPOLLOUT.
> > Reading is same, but you'd wait for EPOLLIN.
>
> I've got a few questions about this approach. The most logical
> way to do this seems to be:
>
> 1) Leave the epoll_wait with the EPOLLIN|EPOLLOUT event flags and
> use epoll_ctl to switch the interest mask for each fd between EPOLLIN
> and EPOLLOUT on a per fd basis.

Which version of epoll do you have? The epoll_wait() function does not
accept an event mask (like you write above, EPOLLIN|EPOLLOUT). It never
had.
But yes, you'd switch interest with epoll_ctl().


> 2) When I'm ready to write, I do a write and if it does not fully
> write and I get the EAGAIN flag, I switch the fd with epoll_ctl(fd,MOD,EPOLLOUT).

As optimization, if the EPOLLOUT bit is already set, you don't need to
keep calling epoll_ctl(fd,MOD,EPOLLOUT).



> However, I get strange behavior when I tried adding fd's with only the
> EPOLLIN interest mask. If I use epoll_wait with both the EPOLLIN and
> EPOLLOUT interest mask, but add fd's with only the EPOLLIN interest mask,
> I still seem to get EPOLLOUT events on the fd.

Again, how the heck do you "use epoll_wait with both the EPOLLIN and
EPOLLOUT"?!? There is not such a thing.




> So, I'm a little confused.

From the wording above, that doesn't seem like a wrong guess.



- Davide




\
 
 \ /
  Last update: 2008-10-27 02:21    [from the cache]
©2003-2011 Jasper Spaans