Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-6]: src/sys/kern Pull up revision 1.68 (requested by thorpej in...



details:   https://anonhg.NetBSD.org/src/rev/3d76a45dda51
branches:  netbsd-1-6
changeset: 529305:3d76a45dda51
user:      tron <tron%NetBSD.org@localhost>
date:      Fri Nov 08 09:31:35 2002 +0000

description:
Pull up revision 1.68 (requested by thorpej in ticket #429):
Fix 2 bugs with MSG_WAITALL.  The first is to not block forever if one is
trying to MSG_PEEK for more than the socket can hold.  The second is that
before sleeping waiting for more data, upcall the protocol telling it you
have just received data so it can kick itself to re-fill the just drained
socket buffer.

diffstat:

 sys/kern/uipc_socket.c |  21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)

diffs (42 lines):

diff -r 8ff83b7f298b -r 3d76a45dda51 sys/kern/uipc_socket.c
--- a/sys/kern/uipc_socket.c    Fri Nov 08 09:28:19 2002 +0000
+++ b/sys/kern/uipc_socket.c    Fri Nov 08 09:31:35 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uipc_socket.c,v 1.66.4.1 2002/06/11 01:59:49 lukem Exp $       */
+/*     $NetBSD: uipc_socket.c,v 1.66.4.2 2002/11/08 09:31:35 tron Exp $        */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -72,7 +72,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.66.4.1 2002/06/11 01:59:49 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.66.4.2 2002/11/08 09:31:35 tron Exp $");
 
 #include "opt_sock_counters.h"
 #include "opt_sosend_loan.h"
@@ -1073,6 +1073,23 @@
                    !sosendallatonce(so) && !nextrecord) {
                        if (so->so_error || so->so_state & SS_CANTRCVMORE)
                                break;
+                       /*
+                        * If we are peeking and the socket receive buffer is
+                        * full, stop since we can't get more data to peek at.
+                        */
+                       if ((flags & MSG_PEEK) && sbspace(&so->so_rcv) <= 0)
+                               break;
+                       /*
+                        * If we've drained the socket buffer, tell the
+                        * protocol in case it needs to do something to
+                        * get it filled again.
+                        */
+                       if ((pr->pr_flags & PR_WANTRCVD) && so->so_pcb)
+                               (*pr->pr_usrreq)(so, PRU_RCVD,
+                                   (struct mbuf *)0,
+                                   (struct mbuf *)(long)flags,
+                                   (struct mbuf *)0,
+                                   (struct proc *)0);
                        error = sbwait(&so->so_rcv);
                        if (error) {
                                sbunlock(&so->so_rcv);



Home | Main Index | Thread Index | Old Index