Re: poll() returns POLLIN but no data ?

joe_at_invalid.address
Date: 06/27/05


Date: 26 Jun 2005 18:52:48 -0500


"Maxim Yegorushkin" <firstname.lastname@gmail.com> writes:

> On Sun, 26 Jun 2005 23:32:46 +0400, David Schwartz
> <davids@webmaster.com> wrote:

> >> Using blocking sockets with select/poll/epoll/... is fine,
> >> read/write won't block if the descriptor has been indicated to be
> >> ready for that operation and this is guarantied by
> >> POSIX. Blocking accept() can block after a socket has been
> >> indicated as ready for read because a client could bail out
> >> before you call accept.
> >
> > It is not guaranteed by POSIX, and it cannot be guaranteed.
>
> I thought this guaranties that
> http://www.opengroup.org/onlinepubs/009695399/functions/select.html
>
> Why can't it be guaranteed?

David has a different idea about what "blocking" means than many other
people do. He includes things like short waits for page faults to be
blocking. I don't, and many others don't, but there it is.

Even if you take his view though, the standard says

  "A descriptor shall be considered ready for reading when a call to
   an input function with O_NONBLOCK clear would not block, whether or
   not the function would transfer data successfully. (The function
   might return data, an end-of-file indication, or an error other
   than one indicating that it is blocked, and in each of these cases
   the descriptor shall be considered ready for reading.)

   A descriptor shall be considered ready for writing when a call to
   an output function with O_NONBLOCK clear would not block, whether
   or not the function would transfer data successfully."

So whatever you define as blocking the standard says it won't. It may
be that the standard is wrong to say this (at least without
qualification), but it does say it.

One thing that can be guaranteed is that you won't change his mind
about it :-)

Joe



Relevant Pages

  • Re: poll() returns POLLIN but no data ?
    ... >> won't block if the descriptor has been indicated to be ready for that ... Blocking acceptcan block ... > It is not guaranteed by POSIX, ... I thought this guaranties that ...
    (comp.unix.programmer)
  • Re: threads vs. processes
    ... A call to an input function with O_NONBLOCK clear means a blocking ... standard doesn't intend that in the definition of "block". ... It says that a descriptor in blocking ... Given that page faults can happen when an input function is called on ...
    (comp.unix.programmer)
  • Re: non blocking sockets
    ... >> you want to say blocking is or isn't, the standard says it won't. ... arguments to indicate which file descriptors are ready for reading, ... descriptor shall be considered ready for reading.) ...
    (comp.unix.programmer)