Re: epoll(7) redux

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 9 Apr 2008, Michael Kerrisk wrote:

> On Wed, Apr 9, 2008 at 1:07 PM, Sam Varshavchik <mrsam@xxxxxxxxxxxxxxx> wrote:
> > Q2
> >
> >   Can two epoll sets wait for the same file descriptor? If so, are events
> > reported to both epoll file descriptors?
> >
> > A2
> >
> >   Yes, and events would be reported to both. However, it is not recommended.
> >
> > =========
> >
> > It's not clear what "not recommended" means. Furthermore, I don't think
> > there's anything wrong with two epoll file descriptors waiting for different
> > events on the same file descriptor. One's waiting for POLLIN, the other for
> > POLLOUT. What's wrong with that?
> 
> Perhaps Davide has some thought to offer here?

You can do it. No problem as far as epoll goes. The "recommended" bit was 
more because it is very easy to get things wrong from an application 
perspective POV, when doing that.
In the case above, first POLLOUT is "almost" always signaled, so you'll 
receive continuous events over there. Second, if both events shows up at 
the same time (say in two different threads) and you do not take care of 
it, you'll end up handling the same fd, at the same time, in two different 
threads.
*Many* users got this wrong, so *many* times, that the "not recommended" 
is the least warning we can issue.



- Davide


--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux