diff options
author | rwatson <rwatson@FreeBSD.org> | 2004-07-12 04:45:46 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2004-07-12 04:45:46 +0000 |
commit | b8ecdf1b3cd43ecab8ad5c7059a68aaa4acd3b51 (patch) | |
tree | 057d953ffcbcf7bfaea687b8f82dcf61b8b9f117 /sys/netgraph | |
parent | b71b19f0a262fc3263f5272cdbebf25e10dca6fa (diff) | |
download | FreeBSD-src-b8ecdf1b3cd43ecab8ad5c7059a68aaa4acd3b51.zip FreeBSD-src-b8ecdf1b3cd43ecab8ad5c7059a68aaa4acd3b51.tar.gz |
Introduce a global mtx 'ngsocketlist_mtx' to protect the global
ng_socket list during insert/delete.
Diffstat (limited to 'sys/netgraph')
-rw-r--r-- | sys/netgraph/ng_socket.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/netgraph/ng_socket.c b/sys/netgraph/ng_socket.c index 9a140b6..52308f4 100644 --- a/sys/netgraph/ng_socket.c +++ b/sys/netgraph/ng_socket.c @@ -55,6 +55,7 @@ #include <sys/lock.h> #include <sys/malloc.h> #include <sys/mbuf.h> +#include <sys/mutex.h> #include <sys/protosw.h> #include <sys/queue.h> #include <sys/signalvar.h> @@ -154,6 +155,9 @@ SYSCTL_INT(_net_graph, OID_AUTO, recvspace, CTLFLAG_RW, /* List of all sockets */ static LIST_HEAD(, ngpcb) ngsocklist; +static struct mtx ngsocketlist_mtx; +MTX_SYSINIT(ngsocketlist, &ngsocketlist_mtx, "ng_socketlist", MTX_DEF); + #define sotongpcb(so) ((struct ngpcb *)(so)->so_pcb) /* If getting unexplained errors returned, set this to "kdb_enter("X"); */ @@ -525,7 +529,9 @@ ng_attach_common(struct socket *so, int type) pcbp->ng_socket = so; /* Add the socket to linked list */ + mtx_lock(&ngsocketlist_mtx); LIST_INSERT_HEAD(&ngsocklist, pcbp, socks); + mtx_unlock(&ngsocketlist_mtx); return (0); } @@ -558,7 +564,9 @@ ng_detach_common(struct ngpcb *pcbp, int which) } pcbp->ng_socket->so_pcb = NULL; pcbp->ng_socket = NULL; + mtx_lock(&ngsocketlist_mtx); LIST_REMOVE(pcbp, socks); + mtx_unlock(&ngsocketlist_mtx); FREE(pcbp, M_PCB); } |