diff options
author | Gleb Smirnoff <glebius@FreeBSD.org> | 2021-10-01 20:38:24 +0000 |
---|---|---|
committer | Gleb Smirnoff <glebius@FreeBSD.org> | 2021-10-01 20:38:24 +0000 |
commit | a37e4fd1ea8ccb2a5e54083d7cfc7b1b1784072d (patch) | |
tree | 798de38876c88d95576b878c53605faac3ae769d | |
parent | 63cb9308a75b99fe057409705bc1b2ac0293f578 (diff) |
Re-style dfcef8771484 to keep the code and variables related to
listening sockets separated from code for generic sockets.
No objection: markj
-rw-r--r-- | sys/kern/uipc_socket.c | 30 |
1 files 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(); |