summaryrefslogtreecommitdiffstats
path: root/sys/netatalk
diff options
context:
space:
mode:
authortanimura <tanimura@FreeBSD.org>2002-05-20 05:41:09 +0000
committertanimura <tanimura@FreeBSD.org>2002-05-20 05:41:09 +0000
commit92d8381dd544a8237b3fd68c4e7fce9bd0903fb2 (patch)
tree2465ddbcecac65f96c5c6d5cef1a4fe3f1ac03f8 /sys/netatalk
parent969293170b27461145f69a538d5abd15fea34ba1 (diff)
downloadFreeBSD-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/netatalk')
-rw-r--r--sys/netatalk/ddp_input.c2
-rw-r--r--sys/netatalk/ddp_pcb.c10
-rw-r--r--sys/netatalk/ddp_usrreq.c10
3 files changed, 20 insertions, 2 deletions
diff --git a/sys/netatalk/ddp_input.c b/sys/netatalk/ddp_input.c
index 4ef497b..f9a06c8 100644
--- a/sys/netatalk/ddp_input.c
+++ b/sys/netatalk/ddp_input.c
@@ -410,7 +410,9 @@ ddp_input( m, ifp, elh, phase )
/*
* And wake up whatever might be waiting for it
*/
+ SOCK_LOCK(ddp->ddp_socket);
sorwakeup( ddp->ddp_socket );
+ SOCK_UNLOCK(ddp->ddp_socket);
}
#if 0
diff --git a/sys/netatalk/ddp_pcb.c b/sys/netatalk/ddp_pcb.c
index fa79cec..63932cc 100644
--- a/sys/netatalk/ddp_pcb.c
+++ b/sys/netatalk/ddp_pcb.c
@@ -110,8 +110,11 @@ ddp_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
s = splnet();
error = at_pcbconnect( ddp, nam, td );
splx(s);
- if ( error == 0 )
+ if ( error == 0 ) {
+ SOCK_LOCK( so );
soisconnected( so );
+ SOCK_UNLOCK( so );
+ }
return(error);
}
@@ -134,7 +137,9 @@ ddp_disconnect(struct socket *so)
at_pcbdisconnect( ddp );
ddp->ddp_fsat.sat_addr.s_node = ATADDR_ANYNODE;
splx(s);
+ SOCK_LOCK( so );
soisdisconnected( so );
+ SOCK_UNLOCK( so );
return(0);
}
@@ -204,7 +209,9 @@ ddp_abort(struct socket *so)
if ( ddp == NULL ) {
return(EINVAL);
}
+ SOCK_LOCK( so );
soisdisconnected( so );
+ SOCK_UNLOCK( so );
s = splnet();
at_pcbdetach( so, ddp );
splx(s);
@@ -440,6 +447,7 @@ at_pcballoc( struct socket *so )
static void
at_pcbdetach( struct socket *so, struct ddpcb *ddp)
{
+ SOCK_LOCK( so );
soisdisconnected( so );
so->so_pcb = 0;
sotryfree(so);
diff --git a/sys/netatalk/ddp_usrreq.c b/sys/netatalk/ddp_usrreq.c
index fa79cec..63932cc 100644
--- a/sys/netatalk/ddp_usrreq.c
+++ b/sys/netatalk/ddp_usrreq.c
@@ -110,8 +110,11 @@ ddp_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
s = splnet();
error = at_pcbconnect( ddp, nam, td );
splx(s);
- if ( error == 0 )
+ if ( error == 0 ) {
+ SOCK_LOCK( so );
soisconnected( so );
+ SOCK_UNLOCK( so );
+ }
return(error);
}
@@ -134,7 +137,9 @@ ddp_disconnect(struct socket *so)
at_pcbdisconnect( ddp );
ddp->ddp_fsat.sat_addr.s_node = ATADDR_ANYNODE;
splx(s);
+ SOCK_LOCK( so );
soisdisconnected( so );
+ SOCK_UNLOCK( so );
return(0);
}
@@ -204,7 +209,9 @@ ddp_abort(struct socket *so)
if ( ddp == NULL ) {
return(EINVAL);
}
+ SOCK_LOCK( so );
soisdisconnected( so );
+ SOCK_UNLOCK( so );
s = splnet();
at_pcbdetach( so, ddp );
splx(s);
@@ -440,6 +447,7 @@ at_pcballoc( struct socket *so )
static void
at_pcbdetach( struct socket *so, struct ddpcb *ddp)
{
+ SOCK_LOCK( so );
soisdisconnected( so );
so->so_pcb = 0;
sotryfree(so);
OpenPOWER on IntegriCloud