summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2006-08-02 00:45:27 +0000
committerrwatson <rwatson@FreeBSD.org>2006-08-02 00:45:27 +0000
commit641d5a5e44351bafed3d2d35ad253cf87dbaec0f (patch)
tree9325d9d24b4cb651705a6ed64a99b8bf64efd3f0
parent38bff79a10be6fe7b2a4ea95e1fb675b03b598c1 (diff)
downloadFreeBSD-src-641d5a5e44351bafed3d2d35ad253cf87dbaec0f.zip
FreeBSD-src-641d5a5e44351bafed3d2d35ad253cf87dbaec0f.tar.gz
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.
-rw-r--r--sys/kern/uipc_socket.c4
1 files changed, 1 insertions, 3 deletions
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);
}
/*
OpenPOWER on IntegriCloud