patch-2.4.18 linux/net/unix/af_unix.c
Next file: linux/net/unix/garbage.c
Previous file: linux/net/sunrpc/sched.c
Back to the patch index
Back to the overall index
- Lines: 62
- Date:
Wed Jan 23 20:24:26 2002
- Orig file:
linux.orig/net/unix/af_unix.c
- Orig date:
Mon Feb 18 20:18:40 2002
diff -Naur -X /home/marcelo/lib/dontdiff linux.orig/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.126 2001/11/13 05:06:28 davem Exp $
+ * Version: $Id: af_unix.c,v 1.126.2.4 2002/01/14 07:07:41 davem Exp $
*
* Fixes:
* Linus Torvalds : Assorted bug cures.
@@ -101,13 +101,14 @@
#include <linux/skbuff.h>
#include <linux/netdevice.h>
#include <net/sock.h>
-#include <net/tcp.h>
+#include <linux/tcp.h>
#include <net/af_unix.h>
#include <linux/proc_fs.h>
#include <net/scm.h>
#include <linux/init.h>
#include <linux/poll.h>
#include <linux/smp_lock.h>
+#include <linux/rtnetlink.h>
#include <asm/checksum.h>
@@ -483,7 +484,7 @@
sk->protinfo.af_unix.dentry=NULL;
sk->protinfo.af_unix.mnt=NULL;
sk->protinfo.af_unix.lock = RW_LOCK_UNLOCKED;
- atomic_set(&sk->protinfo.af_unix.inflight, 0);
+ atomic_set(&sk->protinfo.af_unix.inflight, sock ? 0 : -1);
init_MUTEX(&sk->protinfo.af_unix.readsem);/* single task reading lock */
init_waitqueue_head(&sk->protinfo.af_unix.peer_wait);
sk->protinfo.af_unix.list=NULL;
@@ -990,7 +991,12 @@
unix_state_wunlock(sk);
/* take ten and and send info to listening sock */
- skb_queue_tail(&other->receive_queue,skb);
+ spin_lock(&other->receive_queue.lock);
+ __skb_queue_tail(&other->receive_queue,skb);
+ /* Undo artificially decreased inflight after embrion
+ * is installed to listening socket. */
+ atomic_inc(&newsk->protinfo.af_unix.inflight);
+ spin_unlock(&other->receive_queue.lock);
unix_state_runlock(other);
other->data_ready(other, 0);
sock_put(other);
@@ -1053,8 +1059,12 @@
*/
skb = skb_recv_datagram(sk, 0, flags&O_NONBLOCK, &err);
- if (!skb)
+ if (!skb) {
+ /* This means receive shutdown. */
+ if (err == 0)
+ err = -EINVAL;
goto out;
+ }
tsk = skb->sk;
skb_free_datagram(sk, skb);
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)