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

Next file: linux/net/unix/garbage.c
Previous file: linux/net/sunrpc/xprt.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.8/linux/net/unix/af_unix.c linux/net/unix/af_unix.c
@@ -8,7 +8,7 @@
  *		as published by the Free Software Foundation; either version
  *		2 of the License, or (at your option) any later version.
  *
- * Version:	$Id: af_unix.c,v 1.78 1999/05/27 00:38:41 davem Exp $
+ * Version:	$Id: af_unix.c,v 1.79 1999/06/29 12:36:07 davem Exp $
  *
  * Fixes:
  *		Linus Torvalds	:	Assorted bug cures.
@@ -103,6 +103,7 @@
 #include <net/scm.h>
 #include <linux/init.h>
 #include <linux/poll.h>
+#include <linux/smp_lock.h>
 
 #include <asm/checksum.h>
 
@@ -943,7 +944,7 @@
  *	Send AF_UNIX data.
  */
 
-static int unix_dgram_sendmsg(struct socket *sock, struct msghdr *msg, int len,
+static int do_unix_dgram_sendmsg(struct socket *sock, struct msghdr *msg, int len,
 			      struct scm_cookie *scm)
 {
 	struct sock *sk = sock->sk;
@@ -1040,6 +1041,7 @@
 	
 	if (!unix_peer(sk))
 		unix_unlock(other);
+
 	return len;
 
 out_unlock:
@@ -1050,8 +1052,18 @@
 	return err;
 }
 
+static int unix_dgram_sendmsg(struct socket *sock, struct msghdr *msg, int len,
+			      struct scm_cookie *scm)
+{
+	int retval;
+
+	lock_kernel();
+	retval = do_unix_dgram_sendmsg(sock, msg, len, scm);
+	unlock_kernel();
+	return retval;
+}
 		
-static int unix_stream_sendmsg(struct socket *sock, struct msghdr *msg, int len,
+static int do_unix_stream_sendmsg(struct socket *sock, struct msghdr *msg, int len,
 			       struct scm_cookie *scm)
 {
 	struct sock *sk = sock->sk;
@@ -1120,9 +1132,9 @@
 		
 		if (skb==NULL)
 		{
-			if (sent)
-				goto out;
-			return err;
+			if (!sent)
+				sent = err;
+			goto out;
 		}
 
 		/*
@@ -1141,9 +1153,9 @@
 
 		if (memcpy_fromiovec(skb_put(skb,size), msg->msg_iov, size)) {
 			kfree_skb(skb);
-			if (sent)
-				goto out;
-			return -EFAULT;
+			if (!sent)
+				sent = -EFAULT;
+			goto out;
 		}
 
 		other=unix_peer(sk);
@@ -1155,7 +1167,8 @@
 				goto out;
 			if (!(msg->msg_flags&MSG_NOSIGNAL))
 				send_sig(SIGPIPE,current,0);
-			return -EPIPE;
+			sent = -EPIPE;
+			goto out;
 		}
 
 		skb_queue_tail(&other->receive_queue, skb);
@@ -1166,6 +1179,17 @@
 	return sent;
 }
 
+static int unix_stream_sendmsg(struct socket *sock, struct msghdr *msg, int len,
+			       struct scm_cookie *scm)
+{
+	int retval;
+
+	lock_kernel();
+	retval = do_unix_stream_sendmsg(sock, msg, len, scm);
+	unlock_kernel();
+	return retval;
+}
+
 /*
  *	Sleep until data has arrive. But check for races..
  */
@@ -1180,7 +1204,7 @@
 	}
 }
 
-static int unix_dgram_recvmsg(struct socket *sock, struct msghdr *msg, int size,
+static int do_unix_dgram_recvmsg(struct socket *sock, struct msghdr *msg, int size,
 			      int flags, struct scm_cookie *scm)
 {
 	struct sock *sk = sock->sk;
@@ -1257,8 +1281,18 @@
 	return err;
 }
 
+static int unix_dgram_recvmsg(struct socket *sock, struct msghdr *msg, int size,
+			      int flags, struct scm_cookie *scm)
+{
+	int retval;
 
-static int unix_stream_recvmsg(struct socket *sock, struct msghdr *msg, int size,
+	lock_kernel();
+	retval = do_unix_dgram_recvmsg(sock, msg, size, flags, scm);
+	unlock_kernel();
+	return retval;
+}
+
+static int do_unix_stream_recvmsg(struct socket *sock, struct msghdr *msg, int size,
 			       int flags, struct scm_cookie *scm)
 {
 	struct sock *sk = sock->sk;
@@ -1275,8 +1309,7 @@
 		return -EOPNOTSUPP;
 	if (flags&MSG_WAITALL)
 		target = size;
-		
-		
+
 	msg->msg_namelen = 0;
 
 	/* Lock the socket to prevent queue disordering
@@ -1390,6 +1423,17 @@
 
 	up(&sk->protinfo.af_unix.readsem);
 	return copied;
+}
+
+static int unix_stream_recvmsg(struct socket *sock, struct msghdr *msg, int size,
+			       int flags, struct scm_cookie *scm)
+{
+	int retval;
+
+	lock_kernel();
+	retval = do_unix_stream_recvmsg(sock, msg, size, flags, scm);
+	unlock_kernel();
+	return retval;
 }
 
 static int unix_shutdown(struct socket *sock, int mode)

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)