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.
This commit is contained in:
Robert Watson 2006-08-02 00:45:27 +00:00
parent 3c57a41d7b
commit c0e1415d51
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=160896

View File

@ -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);
}
/*