From 641d5a5e44351bafed3d2d35ad253cf87dbaec0f Mon Sep 17 00:00:00 2001 From: rwatson Date: Wed, 2 Aug 2006 00:45:27 +0000 Subject: Move updated of 'numopensockets' from bottom of sodealloc() to the top, eliminating a second set of identical mutex operations at the bottom. This allows brief exceeding of the max sockets limit, but only by sockets in the last stages of being torn down. --- sys/kern/uipc_socket.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'sys/kern/uipc_socket.c') diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index b5af081..41b9baa 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -291,6 +291,7 @@ sodealloc(struct socket *so) mtx_lock(&so_global_mtx); so->so_gencnt = ++so_gencnt; + --numopensockets; /* Could be below, but faster here. */ mtx_unlock(&so_global_mtx); if (so->so_rcv.sb_hiwat) (void)chgsbsize(so->so_cred->cr_uidinfo, @@ -310,9 +311,6 @@ sodealloc(struct socket *so) SOCKBUF_LOCK_DESTROY(&so->so_snd); SOCKBUF_LOCK_DESTROY(&so->so_rcv); uma_zfree(socket_zone, so); - mtx_lock(&so_global_mtx); - --numopensockets; - mtx_unlock(&so_global_mtx); } /* -- cgit v1.1