Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Apply rev. 1.68 of uipc_socket.c to kttcp_soreceive():



details:   https://anonhg.NetBSD.org/src/rev/b7e772a3c65f
branches:  trunk
changeset: 533541:b7e772a3c65f
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Wed Jul 03 19:36:52 2002 +0000

description:
Apply rev. 1.68 of uipc_socket.c to kttcp_soreceive():

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/dev/kttcp.c |  19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diffs (33 lines):

diff -r 3b0b6710a6b2 -r b7e772a3c65f sys/dev/kttcp.c
--- a/sys/dev/kttcp.c   Wed Jul 03 19:11:41 2002 +0000
+++ b/sys/dev/kttcp.c   Wed Jul 03 19:36:52 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kttcp.c,v 1.2 2002/07/03 19:06:47 thorpej Exp $        */
+/*     $NetBSD: kttcp.c,v 1.3 2002/07/03 19:36:52 thorpej Exp $        */
 
 /*
  * Copyright (c) 2002 Wasabi Systems, Inc.
@@ -643,6 +643,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);
                        SBLASTRECORDCHK(&so->so_rcv,
                            "kttcp_soreceive sbwait 2");
                        SBLASTMBUFCHK(&so->so_rcv,



Home | Main Index | Thread Index | Old Index