Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 16 Sep 2023 09:27:13 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: f44102411e1b - main - sockets: re-check socket state after call to pr_rcvd()
Message-ID:  <202309160927.38G9RDsn016620@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=f44102411e1b16363e91a074c9c403069c550e4d

commit f44102411e1b16363e91a074c9c403069c550e4d
Author:     Greg Becker <becker.greg@att.net>
AuthorDate: 2023-09-09 23:38:24 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-09-15 16:59:46 +0000

    sockets: re-check socket state after call to pr_rcvd()
    
    Socket state may have changed after dropping the receive
    buffer lock in order to call pr_rcvd().  If the buffer is
    empty, re-check the state after reaquiring the lock and
    skip calling sbwait() if the socket is in error or the
    peer has closed.
    
    PR:             212716
    Reviewed by:    markj, glebius
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D41783
---
 sys/kern/uipc_socket.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index ffd5e06c34b7..3c7e5c4cb4bb 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -2429,6 +2429,10 @@ dontblock:
 				VNET_SO_ASSERT(so);
 				pr->pr_rcvd(so, flags);
 				SOCKBUF_LOCK(&so->so_rcv);
+				if (__predict_false(so->so_rcv.sb_mb == NULL &&
+				    (so->so_error || so->so_rerror ||
+				    so->so_rcv.sb_state & SBS_CANTRCVMORE)))
+					break;
 			}
 			SBLASTRECORDCHK(&so->so_rcv);
 			SBLASTMBUFCHK(&so->so_rcv);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202309160927.38G9RDsn016620>