Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Sep 2024 14:55:07 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 441fc34c6f01 - stable/14 - socket: Microoptimize soreceive_stream_locked()
Message-ID:  <202409031455.483Et7wN070854@gitrepo.freebsd.org>

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

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

commit 441fc34c6f01ffe72278f3ba696a3ec06924743d
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-07-05 18:01:29 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-09-03 14:54:43 +0000

    socket: Microoptimize soreceive_stream_locked()
    
    There is no need to hold the sockbuf lock while checking uio_resid.
    No functional change intended.
    
    MFC after:      2 weeks
    Sponsored by:   Klara, Inc.
    Sponsored by:   Stormshield
    
    (cherry picked from commit 6982be38cb7e4254ff4ffbb334cd7e234b5f6cc2)
---
 sys/kern/uipc_socket.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index dfe75978ac39..adb11e08a7ac 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -2555,14 +2555,12 @@ soreceive_stream_locked(struct socket *so, struct sockbuf *sb,
 
 	SOCK_IO_RECV_ASSERT_LOCKED(so);
 
-	SOCKBUF_LOCK(sb);
 	/* Easy one, no space to copyout anything. */
-	if (uio->uio_resid == 0) {
-		error = EINVAL;
-		goto out;
-	}
+	if (uio->uio_resid == 0)
+		return (EINVAL);
 	oresid = uio->uio_resid;
 
+	SOCKBUF_LOCK(sb);
 	/* We will never ever get anything unless we are or were connected. */
 	if (!(so->so_state & (SS_ISCONNECTED|SS_ISDISCONNECTED))) {
 		error = ENOTCONN;



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