odd behavior on select() after shutdown()

Kostik Belousov kostikbel at gmail.com
Mon May 17 19:05:30 UTC 2010


On Tue, May 18, 2010 at 01:08:50AM +0900, Yoshihiko Sarumaru wrote:
> Hi all,
> 
> Select(2) has three arguments to get socket status for read, write and except.
> After upgrading to 8.0-RELEASE, select() after shutdown(SHUT_WR) returns with
> the status exceptfds is set. It means out-of-bound data can be read
> from the socket,
> but recv() with OOB flag returns ECONNRESET, and no packets with urgent flag
> was observed by tcpdump.
> It seems strange for me, but is it an intentional change on 8.x ?
> 
> This behavior breaks net/stone on 8.0-RELEASE.
> http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/141103
> The continuous recv() error on PR might lead by incorrectly setted
> exceptfds on every recv()
> and it should be fixed, but it doesn't matter if above behavior of
> select() doesn't occur.

The patch below would fix the problem at hand. I am wondering what
unintended consequences it might have.

diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c
index eaefd9c..293dbb1 100644
--- a/sys/kern/sys_generic.c
+++ b/sys/kern/sys_generic.c
@@ -996,7 +996,7 @@ done:
 static int select_flags[3] = {
     POLLRDNORM | POLLHUP | POLLERR,
     POLLWRNORM | POLLHUP | POLLERR,
-    POLLRDBAND | POLLHUP | POLLERR
+    POLLRDBAND | POLLERR
 };
 
 /*
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-stable/attachments/20100517/0110bea8/attachment.pgp


More information about the freebsd-stable mailing list