mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* (e)poll and (rd)hup questions
@ 2008-08-26 17:25 Michael Noisternig
  2008-08-26 19:11 ` Davide Libenzi
  2008-08-26 19:37 ` Michael Noisternig
  0 siblings, 2 replies; 3+ messages in thread
From: Michael Noisternig @ 2008-08-26 17:25 UTC (permalink / raw)
  To: linux-kernel

Hello folks,

I hope this is a right place to ask this question. (Sorry if it isn't, 
please hint me where to post in that case.)

This has been bugging me for quite some while now. I'm using epoll in 
default level-triggered mode. I'm polling for input, output, rdhup, and 
forcibly for hup. I figured that when I get EPOLLRDHUP that doesn't mean 
there is no more data to read, presumably I must empty the kernel buffer 
by continously reading from the fd until I get zero as a result 
indicating rdhup. This means EPOLLRDHUP is delivered asynchronously and 
thus is pretty useless to me.

On the other hand, EPOLLHUP seems to be delivered synchronously. If it 
isn't then this means I get constantly notified about a closed fd until 
I have read all data from the kernel buffer and remove the fd from the 
epoll set (which makes being forced to hup notifications useless to me).

(And no, don't tell me to use edge-triggered mode, I have reasons to use 
level-triggered.)

Question: Is my observation correct that EPOLLRDHUP is delivered 
asynchronously in contrast to EPOLLHUP? Or is EPOLLHUP delivered 
asynchronously as well?

Thanks, anwers would help a lot!!!
Michael

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

* Re: (e)poll and (rd)hup questions
  2008-08-26 17:25 (e)poll and (rd)hup questions Michael Noisternig
@ 2008-08-26 19:11 ` Davide Libenzi
  2008-08-26 19:37 ` Michael Noisternig
  1 sibling, 0 replies; 3+ messages in thread
From: Davide Libenzi @ 2008-08-26 19:11 UTC (permalink / raw)
  To: Michael Noisternig; +Cc: linux-kernel

On Tue, 26 Aug 2008, Michael Noisternig wrote:

> Hello folks,
> 
> I hope this is a right place to ask this question. (Sorry if it isn't, please
> hint me where to post in that case.)
> 
> This has been bugging me for quite some while now. I'm using epoll in default
> level-triggered mode. I'm polling for input, output, rdhup, and forcibly for
> hup. I figured that when I get EPOLLRDHUP that doesn't mean there is no more
> data to read, presumably I must empty the kernel buffer by continously reading
> from the fd until I get zero as a result indicating rdhup. This means
> EPOLLRDHUP is delivered asynchronously and thus is pretty useless to me.
> 
> On the other hand, EPOLLHUP seems to be delivered synchronously. If it isn't
> then this means I get constantly notified about a closed fd until I have read
> all data from the kernel buffer and remove the fd from the epoll set (which
> makes being forced to hup notifications useless to me).
> 
> (And no, don't tell me to use edge-triggered mode, I have reasons to use
> level-triggered.)
> 
> Question: Is my observation correct that EPOLLRDHUP is delivered
> asynchronously in contrast to EPOLLHUP? Or is EPOLLHUP delivered
> asynchronously as well?

There's nothing synchronous in epoll WRT userspace. If you use epoll LT, 
you don't need RDHUP. RDHUP was introduced to deal with special 
connection states and epoll ET. Take a peek here for a detailed 
description about how/why RDHUP was introduced:

http://lkml.org/lkml/2003/7/12/116


- Davide



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

* Re: (e)poll and (rd)hup questions
  2008-08-26 17:25 (e)poll and (rd)hup questions Michael Noisternig
  2008-08-26 19:11 ` Davide Libenzi
@ 2008-08-26 19:37 ` Michael Noisternig
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Noisternig @ 2008-08-26 19:37 UTC (permalink / raw)
  To: linux-kernel

David wrote:
> There's nothing synchronous in epoll WRT userspace. If you use epoll LT, 
> you don't need RDHUP. RDHUP was introduced to deal with special 
> connection states and epoll ET. Take a peek here for a detailed 
> description about how/why RDHUP was introduced:
> 
> http://lkml.org/lkml/2003/7/12/116
> 
> 
> - Davide

Thanks a lot for the explanation about RDHUP. Now that leaves me with 
only one question which I'm still not sure about: When I get HUP can 
there still be data in the kernel buffer to read out? (I guess so.)

Thanks again,
Michael

--Original message--
Michael Noisternig schrieb:
> Hello folks,
> 
> I hope this is a right place to ask this question. (Sorry if it isn't, 
> please hint me where to post in that case.)
> 
> This has been bugging me for quite some while now. I'm using epoll in 
> default level-triggered mode. I'm polling for input, output, rdhup, and 
> forcibly for hup. I figured that when I get EPOLLRDHUP that doesn't mean 
> there is no more data to read, presumably I must empty the kernel buffer 
> by continously reading from the fd until I get zero as a result 
> indicating rdhup. This means EPOLLRDHUP is delivered asynchronously and 
> thus is pretty useless to me.
> 
> On the other hand, EPOLLHUP seems to be delivered synchronously. If it 
> isn't then this means I get constantly notified about a closed fd until 
> I have read all data from the kernel buffer and remove the fd from the 
> epoll set (which makes being forced to hup notifications useless to me).
> 
> (And no, don't tell me to use edge-triggered mode, I have reasons to use 
> level-triggered.)
> 
> Question: Is my observation correct that EPOLLRDHUP is delivered 
> asynchronously in contrast to EPOLLHUP? Or is EPOLLHUP delivered 
> asynchronously as well?
> 
> Thanks, anwers would help a lot!!!
> Michael
> 

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

end of thread, other threads:[~2008-08-26 19:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-26 17:25 (e)poll and (rd)hup questions Michael Noisternig
2008-08-26 19:11 ` Davide Libenzi
2008-08-26 19:37 ` Michael Noisternig

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

all inboxes | Powered by JetHome®