lkml.org 
[lkml]   [2002]   [Oct]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: poll() incompatability with POSIX.1-2001
On Mon, 14 Oct 2002, Jogchem de Groot wrote:

> Hello,
>
> There's an incompatability with the poll() implementation in the
> linux-2.4 kernel. (Tried 2.4.18).
>
> According to the POSIX.1-2001 standard select() and poll() should
> return writability (POLLOUT) when connect() initated on a non-blocking
> socket asynchronously completes.
>
> http://www.opengroup.org/onlinepubs/007904975/functions/connect.html
>
> "If the connection cannot be established immediately and O_NONBLOCK is set
> for the file descriptor for the socket, connect() shall fail and set errno to
> [EINPROGRESS], but the connection request shall not be aborted, and the
> connection shall be established asynchronously. Subsequent calls to connect()
> for the same socket, before the connection is established, shall fail and set
> errno to [EALREADY].
>
> When the connection has been established asynchronously, select() and poll()
> shall indicate that the file descriptor for the socket is ready for writing."
>
> On linux-2.4 i noticed the following behaviour:
>
> On connect() success select() returns writability for the socket.
> On connect() failure select() returns readability and writability for the
> socket.
>
> This behaviour is according to the specification.
>
> However with poll() (with events=POLLIN|POLLOUT) i get the following
> behaviour:
>
> On connect() success poll() returns POLLOUT in revents.
> On connect() failure poll() returns POLLIN|POLLHUP|POLLERR in revents.
>
> It does not set the POLLOUT bit here..

This is a failure to connect! The socket is therefore not ready for
writing or reading -ever. This behavior may not be correct, not
because of a failure to set the POLLOUT bit, but because the POLLIN
bit is set. Check if this is really true. I can't duplicate this
on 2.4.18 here because it's hard to get a deferred connect with my
setup.

Cheers,
Dick Johnson
Penguin : Linux version 2.4.18 on an i686 machine (797.90 BogoMips).
The US military has given us many words, FUBAR, SNAFU, now ENRON.
Yes, top management were graduates of West Point and Annapolis.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:30    [W:0.072 / U:1.644 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site