From d297f70246c0ef8b93b1a8a03137075f8635fd8a Mon Sep 17 00:00:00 2001 From: Paul Saab Date: Mon, 29 Nov 2004 23:10:59 +0000 Subject: [PATCH] If soreceive() is called from a socket callback, there's no reason to do a window update to the peer (thru an ACK) from soreceive() itself. TCP will do that upon return from the socket callback. Sending a window update from soreceive() results in a lock reversal. Submitted by: Mohan Srinivasan mohans at yahoo-inc dot com Reviewed by: rwatson --- sys/kern/uipc_socket.c | 8 +++++++- sys/sys/socket.h | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index f5299fd20567..b741f41f56bb 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1388,7 +1388,13 @@ soreceive(so, psa, uio, mp0, controlp, flagsp) } SBLASTRECORDCHK(&so->so_rcv); SBLASTMBUFCHK(&so->so_rcv); - if (pr->pr_flags & PR_WANTRCVD && so->so_pcb) { + /* + * If soreceive() is being done from the socket callback, then + * don't need to generate ACK to peer to update window, since + * ACK will be generated on return to TCP. + */ + if (!(flags & MSG_SOCALLBCK) && + (pr->pr_flags & PR_WANTRCVD) && so->so_pcb) { SOCKBUF_UNLOCK(&so->so_rcv); (*pr->pr_usrreqs->pru_rcvd)(so, flags); SOCKBUF_LOCK(&so->so_rcv); diff --git a/sys/sys/socket.h b/sys/sys/socket.h index 165192bdf441..c5e2a8308971 100644 --- a/sys/sys/socket.h +++ b/sys/sys/socket.h @@ -396,6 +396,9 @@ struct msghdr { #define MSG_NBIO 0x4000 /* FIONBIO mode, used by fifofs */ #define MSG_COMPAT 0x8000 /* used in sendit() */ #endif +#ifdef _KERNEL +#define MSG_SOCALLBCK 0x10000 /* for use by socket callbacks - soreceive (TCP) */ +#endif /* * Header for ancillary data objects in msg_control buffer.