Re: accept() doesn't block as it should in 2.3.x kernels

Pete Wyckoff (wyckoff@ca.sandia.gov)
Sun, 12 Dec 1999 13:45:42 -0800


dcd@tc.fluke.com said:
>
> The following demo code should block on the call to accept
> but it doesn't in 2.3.x, (where x is 24,27,28,30,31, and 32pre2)
>
> 2.2.5, 2.2.13, and 2.2.14pre9 block as expected in accept()
>
> I'm getting
> ENOTCONN "Transport endpoint is not connected"

Looks like the changes to 2.3.15 did not take the accept() case into
account.
-- Pete

--- linux/net/core/datagram.c.orig Sun Dec 12 13:30:40 1999
+++ linux/net/core/datagram.c Sun Dec 12 13:31:50 1999
@@ -20,6 +20,7 @@
* Alan Cox : Datagram iovec handling
* Darryl Miles : Fixed non-blocking SOCK_STREAM.
* Alan Cox : POSIXisms
+ * Pete Wyckoff : Unconnected accept() fix.
*
*/

@@ -82,7 +83,7 @@

/* Sequenced packets can come disconnected. If so we report the problem */
error = -ENOTCONN;
- if(connection_based(sk) && sk->state!=TCP_ESTABLISHED)
+ if(connection_based(sk) && !(sk->state==TCP_ESTABLISHED || sk->state==TCP_LISTEN))
goto out;

/* handle signals */

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