public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
* epoll(7) redux
@ 2008-04-09 11:07 Sam Varshavchik
       [not found] ` <cone.1207739243.602382.23947.500-lO+bjgoT4TKm14v+eVDVcBDJ/jce7dRH@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Sam Varshavchik @ 2008-04-09 11:07 UTC (permalink / raw)
  To: linux-man-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 481 bytes --]

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?


[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: epoll(7) redux
       [not found] ` <cone.1207739243.602382.23947.500-lO+bjgoT4TKm14v+eVDVcBDJ/jce7dRH@public.gmane.org>
@ 2008-04-09 11:15   ` Michael Kerrisk
       [not found]     ` <cfd18e0f0804090415m1ddb36bahce8e6b724e60da7d-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Kerrisk @ 2008-04-09 11:15 UTC (permalink / raw)
  To: Sam Varshavchik, Davide Libenzi; +Cc: linux-man-u79uwXL29TY76Z2rM5mHXA

On Wed, Apr 9, 2008 at 1:07 PM, Sam Varshavchik <mrsam-W1w4QoW4mIDgLSHwZvcCBg@public.gmane.org> 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?



-- 
Michael Kerrisk
Maintainer of the Linux man-pages project
http://www.kernel.org/doc/man-pages/
Want to report a man-pages bug? Look here:
http://www.kernel.org/doc/man-pages/reporting_bugs.html
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: epoll(7) redux
       [not found]     ` <cfd18e0f0804090415m1ddb36bahce8e6b724e60da7d-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2008-04-09 19:15       ` Davide Libenzi
  2008-04-09 22:43         ` Sam Varshavchik
  0 siblings, 1 reply; 6+ messages in thread
From: Davide Libenzi @ 2008-04-09 19:15 UTC (permalink / raw)
  To: Michael Kerrisk; +Cc: Sam Varshavchik, linux-man-u79uwXL29TY76Z2rM5mHXA

On Wed, 9 Apr 2008, Michael Kerrisk wrote:

> On Wed, Apr 9, 2008 at 1:07 PM, Sam Varshavchik <mrsam-W1w4QoW4mIDgLSHwZvcCBg@public.gmane.org> 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-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: epoll(7) redux
  2008-04-09 19:15       ` Davide Libenzi
@ 2008-04-09 22:43         ` Sam Varshavchik
       [not found]           ` <cone.1207780987.222099.27997.500-lO+bjgoT4TKm14v+eVDVcBDJ/jce7dRH@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Sam Varshavchik @ 2008-04-09 22:43 UTC (permalink / raw)
  To: Davide Libenzi; +Cc: Michael Kerrisk, linux-man-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 1601 bytes --]

Davide Libenzi writes:

> On Wed, 9 Apr 2008, Michael Kerrisk wrote:
> 
>> On Wed, Apr 9, 2008 at 1:07 PM, Sam Varshavchik <mrsam-W1w4QoW4mIDgLSHwZvcCBg@public.gmane.org> 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.

That's what I had in mind. One thread has the fd in its epoll fd for POLLIN, 
and handles the read aspect of it. Another thread puts the fd into a 
different epoll fd, for POLLOUT, and handles the writing aspect of it. It 
shouldn't be too difficult for both threads to correctly implement their 
corresponding semantics.


[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: epoll(7) redux
       [not found]           ` <cone.1207780987.222099.27997.500-lO+bjgoT4TKm14v+eVDVcBDJ/jce7dRH@public.gmane.org>
@ 2008-05-21 17:53             ` Michael Kerrisk
       [not found]               ` <483461AE.9080305-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Kerrisk @ 2008-05-21 17:53 UTC (permalink / raw)
  To: Sam Varshavchik
  Cc: Davide Libenzi, Michael Kerrisk, linux-man-u79uwXL29TY76Z2rM5mHXA



Sam Varshavchik wrote:
> Davide Libenzi writes:
> 
>> On Wed, 9 Apr 2008, Michael Kerrisk wrote:
>>
>>> On Wed, Apr 9, 2008 at 1:07 PM, Sam Varshavchik
>>> <mrsam-W1w4QoW4mIDgLSHwZvcCBg@public.gmane.org> 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.
> 
> That's what I had in mind. One thread has the fd in its epoll fd for
> POLLIN, and handles the read aspect of it. Another thread puts the fd
> into a different epoll fd, for POLLOUT, and handles the writing aspect
> of it. It shouldn't be too difficult for both threads to correctly
> implement their corresponding semantics.


So how about I change:

A2. Yes, and events would be reported to both. However, it is
not recommended.

to:

Yes, and events would be reported to both. However, careful programming
may be needed to do this correctly.

?

Cheers,

Michael

-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Found a bug? http://www.kernel.org/doc/man-pages/reporting_bugs.html

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

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

* Re: epoll(7) redux
       [not found]               ` <483461AE.9080305-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2008-05-21 19:01                 ` Davide Libenzi
  0 siblings, 0 replies; 6+ messages in thread
From: Davide Libenzi @ 2008-05-21 19:01 UTC (permalink / raw)
  To: Michael Kerrisk; +Cc: Sam Varshavchik, linux-man-u79uwXL29TY76Z2rM5mHXA

On Wed, 21 May 2008, Michael Kerrisk wrote:

> 
> 
> Sam Varshavchik wrote:
> > Davide Libenzi writes:
> > 
> >> On Wed, 9 Apr 2008, Michael Kerrisk wrote:
> >>
> >>> On Wed, Apr 9, 2008 at 1:07 PM, Sam Varshavchik
> >>> <mrsam-W1w4QoW4mIDgLSHwZvcCBg@public.gmane.org> 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.
> > 
> > That's what I had in mind. One thread has the fd in its epoll fd for
> > POLLIN, and handles the read aspect of it. Another thread puts the fd
> > into a different epoll fd, for POLLOUT, and handles the writing aspect
> > of it. It shouldn't be too difficult for both threads to correctly
> > implement their corresponding semantics.
> 
> 
> So how about I change:
> 
> A2. Yes, and events would be reported to both. However, it is
> not recommended.
> 
> to:
> 
> Yes, and events would be reported to both. However, careful programming
> may be needed to do this correctly.
> 
> ?

Looks OK to me.



- Davide


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

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

end of thread, other threads:[~2008-05-21 19:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-09 11:07 epoll(7) redux Sam Varshavchik
     [not found] ` <cone.1207739243.602382.23947.500-lO+bjgoT4TKm14v+eVDVcBDJ/jce7dRH@public.gmane.org>
2008-04-09 11:15   ` Michael Kerrisk
     [not found]     ` <cfd18e0f0804090415m1ddb36bahce8e6b724e60da7d-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-04-09 19:15       ` Davide Libenzi
2008-04-09 22:43         ` Sam Varshavchik
     [not found]           ` <cone.1207780987.222099.27997.500-lO+bjgoT4TKm14v+eVDVcBDJ/jce7dRH@public.gmane.org>
2008-05-21 17:53             ` Michael Kerrisk
     [not found]               ` <483461AE.9080305-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2008-05-21 19:01                 ` Davide Libenzi

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