Re: poll() returns POLLIN but no data ?
From: William Ahern (william_at_wilbur.25thandClement.com)
Date: 06/27/05
- Next message: Fletcher Glenn: "Re: getservbyname function gives me problems"
- Previous message: Rick Jones: "Re: password (& host?) file lookups, daemons and stray descriptors"
- In reply to: David Schwartz: "Re: poll() returns POLLIN but no data ?"
- Next in thread: Maxim Yegorushkin: "Re: poll() returns POLLIN but no data ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 27 Jun 2005 12:01:00 -0700
David Schwartz <davids@webmaster.com> wrote:
> "Maxim Yegorushkin" <e-maxim@yandex.ru> wrote in message
> news:op.ss054dzbti5cme@localhost.localdomain...
> > On Mon, 27 Jun 2005 00:17:04 +0400, David Schwartz <davids@webmaster.com>
> > wrote:
> >>> Why can't it be guaranteed?
> >>
> >> Same reason no other function call guarantees the future -- things
> >> can
> >> change. If you 'stat' a file and find it's not there, does that guarantee
> >> that a subsequent creation will succeed? If you check the free space on a
> >> volume, does that guarantee that a subsequent write will not run out of
> >> space?
>
> > Now I see. I did not think of another process dealing with the same
> > socket.
>
> That's far from the only reason. For example, suppose you have a UDP
> socket and you get a read indication. Ten minutes later when you go to read
> the datagram, it may have been discarded due to memory pressure. There are
> *many* reasons you might get a 'poll' indication and have a subsequent
> operation block. (With write, it's even simpler -- the write may be too
> large to fit in the buffer without blocking.)
Forget 10 minutes. I recently had to patch an async DNS library which made
the same mistake; namely, thinking that a read indication guaranteed an
actual read would return immediately. The UDP socket was never set
non-blocking, and under heavy DNS querying the async library--and with it
the whole application--would stall within a few seconds.
Somewhat oddly--though one could guess at the assumptions--the TCP socket
was set non-blocking.
- Next message: Fletcher Glenn: "Re: getservbyname function gives me problems"
- Previous message: Rick Jones: "Re: password (& host?) file lookups, daemons and stray descriptors"
- In reply to: David Schwartz: "Re: poll() returns POLLIN but no data ?"
- Next in thread: Maxim Yegorushkin: "Re: poll() returns POLLIN but no data ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|