patch-pre2.0.11 linux/net/core/datagram.c

Next file: linux/net/ipv4/arp.c
Previous file: linux/net/bridge/sysctl_net_bridge.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file pre2.0.10/linux/net/core/datagram.c linux/net/core/datagram.c
@@ -18,6 +18,7 @@
  *		Darryl Miles	:	Fixed non-blocking SOCK_SEQPACKET.
  *		Linus Torvalds	:	BSD semantic fixes.
  *		Alan Cox	:	Datagram iovec handling
+ *		Darryl Miles	:	Fixed non-blocking SOCK_STREAM.
  *
  */
 
@@ -47,6 +48,7 @@
  * Interrupts off so that no packet arrives before we begin sleeping.
  * Otherwise we might miss our wake up
  */
+
 static inline void wait_for_packet(struct sock * sk)
 {
 	unsigned long flags;
@@ -60,6 +62,16 @@
 	lock_sock(sk);
 }
 
+/*
+ *	Is a socket 'connection oriented' ?
+ */
+ 
+static inline int connection_based(struct sock *sk)
+{
+	if(sk->type==SOCK_SEQPACKET || sk->type==SOCK_STREAM)
+		return 1;
+	return 0;
+}
 
 /*
  *	Get a datagram skbuff, understands the peeking, nonblocking wakeups and possible
@@ -92,7 +104,7 @@
 
 		/* Sequenced packets can come disconnected. If so we report the problem */
 		error = -ENOTCONN;
-		if(sk->type==SOCK_SEQPACKET && sk->state!=TCP_ESTABLISHED)
+		if(connection_based(sk) && sk->state!=TCP_ESTABLISHED)
 			goto no_packet;
 
 		/* User doesn't want to wait */
@@ -186,7 +198,7 @@
 				return 1;
 			if (sk->shutdown & RCV_SHUTDOWN)
 				return 1;
-			if (sk->type==SOCK_SEQPACKET && sk->state==TCP_CLOSE)
+			if (connection_based(sk) && sk->state==TCP_CLOSE)
 			{
 				/* Connection closed: Wake up */
 				return(1);
@@ -203,7 +215,7 @@
 				return 1;
 			if (sk->shutdown & SEND_SHUTDOWN)
 				return 1;
-			if (sk->type==SOCK_SEQPACKET && sk->state==TCP_SYN_SENT)
+			if (connection_based(sk) && sk->state==TCP_SYN_SENT)
 			{
 				/* Connection still in progress */
 				break;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this