summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_socket.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2004-06-12 16:08:41 +0000
committerrwatson <rwatson@FreeBSD.org>2004-06-12 16:08:41 +0000
commit7bfe3e80fc4fa11f091353498f3ce7475f7beec8 (patch)
tree6d7ee4d7e1232a2656227e586c0d50921c10cb53 /sys/kern/uipc_socket.c
parentad8388ad62dec33a4bf8116aaf62c2f3fe1b5505 (diff)
downloadFreeBSD-src-7bfe3e80fc4fa11f091353498f3ce7475f7beec8.zip
FreeBSD-src-7bfe3e80fc4fa11f091353498f3ce7475f7beec8.tar.gz
Introduce a mutex into struct sockbuf, sb_mtx, which will be used to
protect fields in the socket buffer. Add accessor macros to use the mutex (SOCKBUF_*()). Initialize the mutex in soalloc(), and destroy it in sodealloc(). Add addition, add SOCK_*() access macros which will protect most remaining fields in the socket; for the time being, use the receive socket buffer mutex to implement socket level locking to reduce memory overhead. Submitted by: sam Sponosored by: FreeBSD Foundation Obtained from: BSD/OS
Diffstat (limited to 'sys/kern/uipc_socket.c')
-rw-r--r--sys/kern/uipc_socket.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 690c28a..66a10d9f 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -144,6 +144,8 @@ soalloc(int mflags)
return so;
}
#endif
+ SOCKBUF_LOCK_INIT(&so->so_snd, "so_snd");
+ SOCKBUF_LOCK_INIT(&so->so_rcv, "so_rcv");
/* XXX race condition for reentrant kernel */
so->so_gencnt = ++so_gencnt;
/* sx_init(&so->so_sxlock, "socket sxlock"); */
@@ -245,6 +247,8 @@ sodealloc(struct socket *so)
mac_destroy_socket(so);
#endif
crfree(so->so_cred);
+ SOCKBUF_LOCK_DESTROY(&so->so_snd);
+ SOCKBUF_LOCK_DESTROY(&so->so_rcv);
/* sx_destroy(&so->so_sxlock); */
uma_zfree(socket_zone, so);
--numopensockets;
OpenPOWER on IntegriCloud