patch-1.3.77 linux/include/net/sock.h

Next file: linux/kernel/fork.c
Previous file: linux/include/linux/netdevice.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.76/linux/include/net/sock.h linux/include/net/sock.h
@@ -55,6 +55,8 @@
 
 #include <linux/igmp.h>
 
+#include <asm/atomic.h>
+
 /* Think big (also on some systems a byte is faster) */
 #define SOCK_ARRAY_SIZE	256
 
@@ -149,8 +151,8 @@
 struct sock 
 {
 	struct options		*opt;
-	volatile unsigned long	wmem_alloc;
-	volatile unsigned long	rmem_alloc;
+	atomic_t		wmem_alloc;
+	atomic_t		rmem_alloc;
 	unsigned long		allocation;		/* Allocation mode */
 	__u32			write_seq;
 	__u32			sent_seq;
@@ -484,14 +486,10 @@
 
 extern __inline__ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
 {
-	unsigned long flags;
-	if(sk->rmem_alloc + skb->truesize >= sk->rcvbuf)
+	if (sk->rmem_alloc + skb->truesize >= sk->rcvbuf)
 		return -ENOMEM;
-	save_flags(flags);
-	cli();
-	sk->rmem_alloc+=skb->truesize;
+	atomic_add(skb->truesize, &sk->rmem_alloc);
 	skb->sk=sk;
-	restore_flags(flags);
 	skb_queue_tail(&sk->receive_queue,skb);
 	if(!sk->dead)
 		sk->data_ready(sk,skb->len);

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