git: a37e4fd1ea8c - main - Re-style dfcef8771484 to keep the code and variables related to listening sockets separated from code for generic sockets.
Gleb Smirnoff
glebius at FreeBSD.org
Fri Oct 1 20:40:19 UTC 2021
The branch main has been updated by glebius:
URL: https://cgit.FreeBSD.org/src/commit/?id=a37e4fd1ea8ccb2a5e54083d7cfc7b1b1784072d
commit a37e4fd1ea8ccb2a5e54083d7cfc7b1b1784072d
Author: Gleb Smirnoff <glebius at FreeBSD.org>
AuthorDate: 2021-10-01 20:38:24 +0000
Commit: Gleb Smirnoff <glebius at FreeBSD.org>
CommitDate: 2021-10-01 20:38:24 +0000
Re-style dfcef8771484 to keep the code and variables related to
listening sockets separated from code for generic sockets.
No objection: markj
---
sys/kern/uipc_socket.c | 30 ++++++++++++++++++------------
1 file changed, 18 insertions(+), 12 deletions(-)
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 1f999108dd71..267a33feac3b 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -1225,9 +1225,8 @@ int
soclose(struct socket *so)
{
struct accept_queue lqueue;
- struct socket *sp, *tsp;
int error = 0;
- bool last __diagused;
+ bool listening, last __diagused;
KASSERT(!(so->so_state & SS_NOFDREF), ("soclose: SS_NOFDREF on enter"));
@@ -1261,9 +1260,11 @@ drop:
if (so->so_proto->pr_usrreqs->pru_close != NULL)
(*so->so_proto->pr_usrreqs->pru_close)(so);
- TAILQ_INIT(&lqueue);
SOCK_LOCK(so);
- if (SOLISTENING(so)) {
+ if ((listening = SOLISTENING(so))) {
+ struct socket *sp;
+
+ TAILQ_INIT(&lqueue);
TAILQ_SWAP(&lqueue, &so->sol_incomp, socket, so_list);
TAILQ_CONCAT(&lqueue, &so->sol_comp, so_list);
@@ -1282,14 +1283,19 @@ drop:
KASSERT((so->so_state & SS_NOFDREF) == 0, ("soclose: NOFDREF"));
so->so_state |= SS_NOFDREF;
sorele(so);
- TAILQ_FOREACH_SAFE(sp, &lqueue, so_list, tsp) {
- SOCK_LOCK(sp);
- if (refcount_load(&sp->so_count) == 0) {
- SOCK_UNLOCK(sp);
- soabort(sp);
- } else {
- /* See the handling of queued sockets in sofree(). */
- SOCK_UNLOCK(sp);
+ if (listening) {
+ struct socket *sp, *tsp;
+
+ TAILQ_FOREACH_SAFE(sp, &lqueue, so_list, tsp) {
+ SOCK_LOCK(sp);
+ if (refcount_load(&sp->so_count) == 0) {
+ SOCK_UNLOCK(sp);
+ soabort(sp);
+ } else {
+ /* See the handling of queued sockets
+ in sofree(). */
+ SOCK_UNLOCK(sp);
+ }
}
}
CURVNET_RESTORE();
More information about the dev-commits-src-main
mailing list