summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2004-12-23 00:59:43 +0000
committerrwatson <rwatson@FreeBSD.org>2004-12-23 00:59:43 +0000
commitfd297e39399daf77085922d0d9251b4d460e9d6f (patch)
treea9bb389459a794c189fc39aaac8b2885e54b2cff /sys/kern
parent82dbdac8b7ad99e683f1c59e04700706a2ece901 (diff)
downloadFreeBSD-src-fd297e39399daf77085922d0d9251b4d460e9d6f.zip
FreeBSD-src-fd297e39399daf77085922d0d9251b4d460e9d6f.tar.gz
In soalloc(), simplify the mac_init_socket() handling to remove
unnecessary use of a global variable and simplify the return case. While here, use ()'s around return values. In sodealloc(), remove a comment about why we bump the gencnt and decrement the socket count separately. It doesn't add substantially to the reading, and clutters the function. MFC after: 2 weeks
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/uipc_socket.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 8b04ec6..97d1f63 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -148,18 +148,13 @@ struct socket *
soalloc(int mflags)
{
struct socket *so;
-#ifdef MAC
- int error;
-#endif
so = uma_zalloc(socket_zone, mflags | M_ZERO);
if (so != NULL) {
#ifdef MAC
- error = mac_init_socket(so, mflags);
- if (error != 0) {
+ if (mac_init_socket(so, mflags) != 0) {
uma_zfree(socket_zone, so);
- so = NULL;
- return so;
+ return (NULL);
}
#endif
SOCKBUF_LOCK_INIT(&so->so_snd, "so_snd");
@@ -171,7 +166,7 @@ soalloc(int mflags)
++numopensockets;
mtx_unlock(&so_global_mtx);
}
- return so;
+ return (so);
}
/*
@@ -275,12 +270,6 @@ sodealloc(struct socket *so)
SOCKBUF_LOCK_DESTROY(&so->so_rcv);
/* sx_destroy(&so->so_sxlock); */
uma_zfree(socket_zone, so);
- /*
- * XXXRW: Seems like a shame to grab the mutex again down here, but
- * we don't want to decrement the socket count until after we free
- * the socket, and we can't increment the gencnt on the socket after
- * we free, it so...
- */
mtx_lock(&so_global_mtx);
--numopensockets;
mtx_unlock(&so_global_mtx);
OpenPOWER on IntegriCloud