patch-1.3.68 linux/net/unix/af_unix.c

Next file: linux/scripts/Configure
Previous file: linux/net/netrom/nr_subr.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.67/linux/net/unix/af_unix.c linux/net/unix/af_unix.c
@@ -20,6 +20,7 @@
  *		Alan Cox	:	Limit size of allocated blocks.
  *		Alan Cox	:	Fixed the stupid socketpair bug.
  *		Alan Cox	:	BSD compatibility fine tuning.
+ *		Alan Cox	:	Fixed a bug in connect when interrupted.
  *
  *
  * Known differences from reference BSD that was tested:
@@ -69,8 +70,9 @@
 #define min(a,b)	(((a)<(b))?(a):(b))
 
 /*
- * Make sure the unix name is null-terminated.
+ *	Make sure the unix name is null-terminated.
  */
+ 
 static inline void unix_mkname(struct sockaddr_un * sunaddr, unsigned long len)
 {
 	if (len >= sizeof(*sunaddr))
@@ -468,9 +470,13 @@
 			sock->state=SS_UNCONNECTED;
 			return -ECONNREFUSED;
 		}
-		if(sock->state==SS_CONNECTING)
+		if(sock->state!=SS_CONNECTING)
+			return -EISCONN;
+		if(flags&O_NONBLOCK)
 			return -EALREADY;
-		return -EISCONN;
+		/*
+		 *	Drop through the connect up logic to the wait.
+		 */
 	}
 	
 	if(addr_len < sizeof(sunaddr->sun_family)+1 || sunaddr->sun_family!=AF_UNIX)
@@ -478,15 +484,14 @@
 		
 	unix_mkname(sunaddr, addr_len);
 		
-	if(sk->type==SOCK_DGRAM && sk->protinfo.af_unix.other)
-	{
-		sk->protinfo.af_unix.other->protinfo.af_unix.locks--;
-		sk->protinfo.af_unix.other=NULL;
-		sock->state=SS_UNCONNECTED;
-	}
-
-	if(sock->type==SOCK_DGRAM)
+	if(sk->type==SOCK_DGRAM)
 	{
+		if(sk->protinfo.af_unix.other)
+		{
+			sk->protinfo.af_unix.other->protinfo.af_unix.locks--;
+			sk->protinfo.af_unix.other=NULL;
+			sock->state=SS_UNCONNECTED;
+		}
 		other=unix_find_other(sunaddr->sun_path, &err);
 		if(other==NULL)
 			return err;

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