public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mike Jagdis <jaggy@purplet.demon.co.uk>
To: David Schwartz <davids@webmaster.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: PROBLEM: select() says closed socket readable
Date: Thu, 23 Aug 2001 11:30:34 +0100	[thread overview]
Message-ID: <3B84DB4A.5050707@purplet.demon.co.uk> (raw)
In-Reply-To: <NOEJJDACGOHCKNCOGFOMAECLDGAA.davids@webmaster.com>

David Schwartz wrote:

[assumptions deleted]

> 	Of course, this isn't so much of a benefit that it's worth violating a
> standard like POSIX. But it could be considered enough of a benefit that
> it's worth not being compatable outside the bounds of such a standard.

Let's think about the _facts_ for a second. In the case where select on
an unconnected socket succeeds (because a read would not block) a
process that does this would not sleep in select. If the select does
not succeed (because the socket is not ready to read) then the process
sleeps.

In the first case the process either eats CPU time or gets an error
when it reads the socket. But does it handle the error? Does it even
do the read - why should it read the unconnected socket at all?

In the second case the process either hangs or behaves as expected.
It may even recover gracefully if the socket is subsequently connected.

Case 1 leads to spin-or-die and case 2 leads to block-and-work.

Case 1 assumes that selecting for read on an unconnected socket is
an error. Case 2 doesn't - an unconnected socket is simply never
"ready to read".

Other systems use the "ready to read" interpretation. The Single
UNIX Spec states "ready to read". The Linux man page uses "ready
to read" but adds a parenthetical "read will not block" to allow
EOF. Linux itself implements "will not block".

I can find nothing that even suggests that selecting on an unconnected
socket is an error.

Linux is wrong. Patch follows.

				Mike


  reply	other threads:[~2001-08-23 10:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-18  3:28 PROBLEM: select() says closed socket readable Jay Rogers
2001-08-18 16:27 ` kuznet
2001-08-18 22:52   ` Ton Hospel
2001-08-20 14:34   ` Jay Rogers
2001-08-20 15:03     ` David S. Miller
2001-08-20 15:29       ` Udo A. Steinberg
2001-08-21  9:02       ` Mike Jagdis
2001-08-21 17:35         ` David Schwartz
2001-08-21 18:38           ` Alan Cox
2001-08-21 19:01             ` David Schwartz
2001-08-22  9:26           ` Mike Jagdis
2001-08-22 21:40             ` David Schwartz
2001-08-23 10:30               ` Mike Jagdis [this message]
2001-08-23 10:56               ` [PATCH] " Mike Jagdis
2001-08-20 19:48     ` PROBLEM: " David Schwartz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3B84DB4A.5050707@purplet.demon.co.uk \
    --to=jaggy@purplet.demon.co.uk \
    --cc=davids@webmaster.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox