summaryrefslogtreecommitdiffstats
path: root/sys/netatm/atm_aal5.c
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/netatm/atm_aal5.c
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/netatm/atm_aal5.c')
-rw-r--r--sys/netatm/atm_aal5.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/sys/netatm/atm_aal5.c b/sys/netatm/atm_aal5.c
index ab6a95a..63caed2 100644
--- a/sys/netatm/atm_aal5.c
+++ b/sys/netatm/atm_aal5.c
@@ -771,19 +771,24 @@ atm_aal5_cpcs_data(tok, m)
* Ensure that the socket is able to receive data and
* that there's room in the socket buffer
*/
+ SOCK_LOCK(so);
if (((so->so_state & SS_ISCONNECTED) == 0) ||
(so->so_state & SS_CANTRCVMORE) ||
(len > sbspace(&so->so_rcv))) {
+ SOCK_UNLOCK(so);
atm_sock_stat.as_indrop[atp->atp_type]++;
KB_FREEALL(m);
return;
}
+ SOCK_UNLOCK(so);
/*
* Queue the data and notify the user
*/
sbappendrecord(&so->so_rcv, m);
+ SOCK_LOCK(so);
sorwakeup(so);
+ SOCK_UNLOCK(so);
return;
}
@@ -835,9 +840,12 @@ atm_aal5_ctloutput(so, sopt)
case T_ATM_ADD_LEAF:
case T_ATM_DROP_LEAF:
+ SOCK_LOCK(so);
if ((so->so_state & SS_ISCONNECTED) == 0) {
+ SOCK_UNLOCK(so);
ATM_RETERR(ENOTCONN);
- }
+ } else
+ SOCK_UNLOCK(so);
break;
case T_ATM_CAUSE:
@@ -845,9 +853,12 @@ atm_aal5_ctloutput(so, sopt)
break;
default:
+ SOCK_LOCK(so);
if (so->so_state & SS_ISCONNECTED) {
+ SOCK_UNLOCK(so);
ATM_RETERR(EISCONN);
- }
+ } else
+ SOCK_UNLOCK(so);
break;
}
OpenPOWER on IntegriCloud