patch-2.4.0-test10 linux/net/ipv4/udp.c

Next file: linux/net/ipv4/utils.c
Previous file: linux/net/ipv4/tcp_timer.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test9/linux/net/ipv4/udp.c linux/net/ipv4/udp.c
@@ -5,7 +5,7 @@
  *
  *		The User Datagram Protocol (UDP).
  *
- * Version:	$Id: udp.c,v 1.87 2000/09/20 02:11:34 davem Exp $
+ * Version:	$Id: udp.c,v 1.90 2000/10/18 18:04:22 davem Exp $
  *
  * Authors:	Ross Biro, <bir7@leland.Stanford.Edu>
  *		Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
@@ -677,8 +677,6 @@
 	if (flags & MSG_ERRQUEUE)
 		return ip_recv_error(sk, msg, len);
 
-
- retry:
 	/*
 	 *	From here the generic datagram does a lot of the work. Come
 	 *	the finished NET3, it will do _ALL_ the work!
@@ -734,21 +732,22 @@
 csum_copy_err:
 	UDP_INC_STATS_BH(UdpInErrors);
 
-	if (flags&(MSG_PEEK|MSG_DONTWAIT)) {
-		struct sk_buff *skb2; 
-
+	/* Clear queue. */
+	if (flags&MSG_PEEK) {
+		int clear = 0;
 		spin_lock_irq(&sk->receive_queue.lock);
-		skb2 = skb_peek(&sk->receive_queue); 
-		if ((flags & MSG_PEEK) && skb == skb2) { 
+		if (skb == skb_peek(&sk->receive_queue)) {
 			__skb_unlink(skb, &sk->receive_queue);
+			clear = 1;
 		}
 		spin_unlock_irq(&sk->receive_queue.lock);
-		skb_free_datagram(sk, skb); 
-		if ((flags & MSG_DONTWAIT) && !skb2) 
-			return -EAGAIN; 
-	} else 
-		skb_free_datagram(sk, skb);
-	goto retry; 		
+		if (clear)
+			kfree_skb(skb);
+	}
+
+	skb_free_datagram(sk, skb);
+
+	return -EAGAIN;	
 }
 
 int udp_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
@@ -1029,7 +1028,7 @@
 			if (sk->family != PF_INET)
 				continue;
 			pos += 128;
-			if (pos < offset)
+			if (pos <= offset)
 				continue;
 			get_udp_sock(sk, tmpbuf, i);
 			len += sprintf(buffer+len, "%-127s\n", tmpbuf);

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