Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 5 Feb 2025 22:30:54 GMT
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 9ef38a01aea8 - main - unix: remove always true check from uipc_attach
Message-ID:  <202502052230.515MUsOJ082904@gitrepo.freebsd.org>

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

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

commit 9ef38a01aea87afa6a49fc90411cf8de5ac73b28
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2025-02-05 22:24:27 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2025-02-05 22:24:27 +0000

    unix: remove always true check from uipc_attach
    
    This is pr_attach method, it is always called on a newborn socket.  The
    condition was always true at least since 6d32873c2930.
---
 sys/kern/uipc_usrreq.c | 52 ++++++++++++++++++++++++--------------------------
 1 file changed, 25 insertions(+), 27 deletions(-)

diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c
index c1f1c07da268..a67e105a1447 100644
--- a/sys/kern/uipc_usrreq.c
+++ b/sys/kern/uipc_usrreq.c
@@ -445,37 +445,35 @@ uipc_attach(struct socket *so, int proto, struct thread *td)
 	bool locked;
 
 	KASSERT(so->so_pcb == NULL, ("uipc_attach: so_pcb != NULL"));
-	if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) {
-		switch (so->so_type) {
-		case SOCK_STREAM:
-			sendspace = unpst_sendspace;
-			recvspace = unpst_recvspace;
-			break;
+	switch (so->so_type) {
+	case SOCK_STREAM:
+		sendspace = unpst_sendspace;
+		recvspace = unpst_recvspace;
+		break;
 
-		case SOCK_DGRAM:
-			STAILQ_INIT(&so->so_rcv.uxdg_mb);
-			STAILQ_INIT(&so->so_snd.uxdg_mb);
-			TAILQ_INIT(&so->so_rcv.uxdg_conns);
-			/*
-			 * Since send buffer is either bypassed or is a part
-			 * of one-to-many receive buffer, we assign both space
-			 * limits to unpdg_recvspace.
-			 */
-			sendspace = recvspace = unpdg_recvspace;
-			break;
+	case SOCK_DGRAM:
+		STAILQ_INIT(&so->so_rcv.uxdg_mb);
+		STAILQ_INIT(&so->so_snd.uxdg_mb);
+		TAILQ_INIT(&so->so_rcv.uxdg_conns);
+		/*
+		 * Since send buffer is either bypassed or is a part
+		 * of one-to-many receive buffer, we assign both space
+		 * limits to unpdg_recvspace.
+		 */
+		sendspace = recvspace = unpdg_recvspace;
+		break;
 
-		case SOCK_SEQPACKET:
-			sendspace = unpsp_sendspace;
-			recvspace = unpsp_recvspace;
-			break;
+	case SOCK_SEQPACKET:
+		sendspace = unpsp_sendspace;
+		recvspace = unpsp_recvspace;
+		break;
 
-		default:
-			panic("uipc_attach");
-		}
-		error = soreserve(so, sendspace, recvspace);
-		if (error)
-			return (error);
+	default:
+		panic("uipc_attach");
 	}
+	error = soreserve(so, sendspace, recvspace);
+	if (error)
+		return (error);
 	unp = uma_zalloc(unp_zone, M_NOWAIT | M_ZERO);
 	if (unp == NULL)
 		return (ENOBUFS);



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