diff options
author | tanimura <tanimura@FreeBSD.org> | 2002-05-20 05:41:09 +0000 |
---|---|---|
committer | tanimura <tanimura@FreeBSD.org> | 2002-05-20 05:41:09 +0000 |
commit | 92d8381dd544a8237b3fd68c4e7fce9bd0903fb2 (patch) | |
tree | 2465ddbcecac65f96c5c6d5cef1a4fe3f1ac03f8 /sys/netipx/ipx_pcb.c | |
parent | 969293170b27461145f69a538d5abd15fea34ba1 (diff) | |
download | FreeBSD-src-92d8381dd544a8237b3fd68c4e7fce9bd0903fb2.zip FreeBSD-src-92d8381dd544a8237b3fd68c4e7fce9bd0903fb2.tar.gz |
Lock down a socket, milestone 1.
o Add a mutex (sb_mtx) to struct sockbuf. This protects the data in a
socket buffer. The mutex in the receive buffer also protects the data
in struct socket.
o Determine the lock strategy for each members in struct socket.
o Lock down the following members:
- so_count
- so_options
- so_linger
- so_state
o Remove *_locked() socket APIs. Make the following socket APIs
touching the members above now require a locked socket:
- sodisconnect()
- soisconnected()
- soisconnecting()
- soisdisconnected()
- soisdisconnecting()
- sofree()
- soref()
- sorele()
- sorwakeup()
- sotryfree()
- sowakeup()
- sowwakeup()
Reviewed by: alfred
Diffstat (limited to 'sys/netipx/ipx_pcb.c')
-rw-r--r-- | sys/netipx/ipx_pcb.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/sys/netipx/ipx_pcb.c b/sys/netipx/ipx_pcb.c index 8fe9796..ebe20bd 100644 --- a/sys/netipx/ipx_pcb.c +++ b/sys/netipx/ipx_pcb.c @@ -156,8 +156,12 @@ ipx_pcbconnect(ipxp, nam, td) */ ro = &ipxp->ipxp_route; dst = &satoipx_addr(ro->ro_dst); - if (ipxp->ipxp_socket->so_options & SO_DONTROUTE) + SOCK_LOCK(ipxp->ipxp_socket); + if (ipxp->ipxp_socket->so_options & SO_DONTROUTE) { + SOCK_UNLOCK(ipxp->ipxp_socket); goto flush; + } + SOCK_UNLOCK(ipxp->ipxp_socket); if (!ipx_neteq(ipxp->ipxp_lastdst, sipx->sipx_addr)) goto flush; if (!ipx_hosteq(ipxp->ipxp_lastdst, sipx->sipx_addr)) { @@ -172,15 +176,18 @@ ipx_pcbconnect(ipxp, nam, td) } }/* else cached route is ok; do nothing */ ipxp->ipxp_lastdst = sipx->sipx_addr; + SOCK_LOCK(ipxp->ipxp_socket); if ((ipxp->ipxp_socket->so_options & SO_DONTROUTE) == 0 && /*XXX*/ (ro->ro_rt == NULL || ro->ro_rt->rt_ifp == NULL)) { + SOCK_UNLOCK(ipxp->ipxp_socket); /* No route yet, so try to acquire one */ ro->ro_dst.sa_family = AF_IPX; ro->ro_dst.sa_len = sizeof(ro->ro_dst); *dst = sipx->sipx_addr; dst->x_port = 0; rtalloc(ro); - } + } else + SOCK_UNLOCK(ipxp->ipxp_socket); if (ipx_neteqnn(ipxp->ipxp_laddr.x_net, ipx_zeronet)) { /* * If route is known or can be allocated now, @@ -257,8 +264,12 @@ ipx_pcbdisconnect(ipxp) { ipxp->ipxp_faddr = zeroipx_addr; - if (ipxp->ipxp_socket->so_state & SS_NOFDREF) + SOCK_LOCK(ipxp->ipxp_socket); + if (ipxp->ipxp_socket->so_state & SS_NOFDREF) { + SOCK_UNLOCK(ipxp->ipxp_socket); ipx_pcbdetach(ipxp); + } else + SOCK_UNLOCK(ipxp->ipxp_socket); } void @@ -268,6 +279,7 @@ ipx_pcbdetach(ipxp) struct socket *so = ipxp->ipxp_socket; so->so_pcb = 0; + SOCK_LOCK(so); sotryfree(so); if (ipxp->ipxp_route.ro_rt != NULL) rtfree(ipxp->ipxp_route.ro_rt); |