summaryrefslogtreecommitdiffstats
path: root/sys/rpc
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2007-03-25 21:44:24 +0000
committerrwatson <rwatson@FreeBSD.org>2007-03-25 21:44:24 +0000
commit95d0d388ac9c14373708101bce1a8922f43d6386 (patch)
tree2a9868a79ad5d825b979b09781ee735038f27a9e /sys/rpc
parent7c1dc0e01b889e8d7c88d5ea8bb8c94a511981b1 (diff)
downloadFreeBSD-src-95d0d388ac9c14373708101bce1a8922f43d6386.zip
FreeBSD-src-95d0d388ac9c14373708101bce1a8922f43d6386.tar.gz
Replace GIANT_REQUIRED's present for socket locking with NET_LOCK_GIANT().
If/when someone does the necessary MPSAFEty locking for the NFSv4 client, the socket code is generally MPSAFE now. Spotted by: kris
Diffstat (limited to 'sys/rpc')
-rw-r--r--sys/rpc/rpcclnt.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/sys/rpc/rpcclnt.c b/sys/rpc/rpcclnt.c
index 04e1bce..d666e1b 100644
--- a/sys/rpc/rpcclnt.c
+++ b/sys/rpc/rpcclnt.c
@@ -360,15 +360,15 @@ rpcclnt_connect(rpc, td)
RPC_RETURN(EFAULT);
}
- GIANT_REQUIRED; /* XXX until socket locking done */
-
/* create the socket */
rpc->rc_so = NULL;
saddr = rpc->rc_name;
+ NET_LOCK_GIANT();
error = socreate(saddr->sa_family, &rpc->rc_so, rpc->rc_sotype,
rpc->rc_soproto, td->td_ucred, td);
+ NET_UNLOCK_GIANT();
if (error) {
RPCDEBUG("error %d in socreate()", error);
@@ -624,13 +624,13 @@ rpcclnt_disconnect(rpc)
{
struct socket *so;
- GIANT_REQUIRED; /* XXX until socket locking done */
-
if (rpc->rc_so) {
so = rpc->rc_so;
rpc->rc_so = NULL;
+ NET_LOCK_GIANT();
soshutdown(so, 2);
soclose(so);
+ NET_UNLOCK_GIANT();
}
}
@@ -678,8 +678,6 @@ rpcclnt_send(so, nam, top, rep)
#endif
int error, soflags, flags;
- GIANT_REQUIRED; /* XXX until socket locking done */
-
if (rep) {
if (rep->r_flags & R_SOFTTERM) {
m_freem(top);
@@ -705,7 +703,14 @@ rpcclnt_send(so, nam, top, rep)
else
flags = 0;
+ /*
+ * XXXRW: If/when this code becomes MPSAFE itself, Giant might have
+ * to be conditionally acquired earlier for the stack so has to avoid
+ * lock order reversals with any locks held over rpcclnt_send().
+ */
+ NET_LOCK_GIANT();
error = sosend(so, sendnam, NULL, top, NULL, flags, td);
+ NET_UNLOCK_GIANT();
if (error) {
if (rep) {
@@ -763,8 +768,6 @@ rpcclnt_receive(rep, aname, mp, td)
#endif
int error, sotype, rcvflg;
- GIANT_REQUIRED; /* XXX until socket locking done */
-
/*
* Set up arguments for soreceive()
*/
@@ -835,7 +838,9 @@ tryagain:
#endif
do {
rcvflg = MSG_WAITALL;
+ NET_LOCK_GIANT();
error = soreceive(so, NULL, &auio, NULL, NULL, &rcvflg);
+ NET_UNLOCK_GIANT();
if (error == EWOULDBLOCK && rep) {
if (rep->r_flags & R_SOFTTERM)
RPC_RETURN(EINTR);
@@ -868,7 +873,9 @@ tryagain:
auio.uio_resid = len;
do {
rcvflg = MSG_WAITALL;
+ NET_LOCK_GIANT();
error = soreceive(so, NULL, &auio, mp, NULL, &rcvflg);
+ NET_UNLOCK_GIANT();
} while (error == EWOULDBLOCK || error == EINTR ||
error == ERESTART);
if (!error && auio.uio_resid > 0) {
@@ -894,7 +901,9 @@ tryagain:
#endif
do {
rcvflg = 0;
+ NET_LOCK_GIANT();
error = soreceive(so, NULL, &auio, mp, &control, &rcvflg);
+ NET_UNLOCK_GIANT();
if (control)
m_freem(control);
if (error == EWOULDBLOCK && rep) {
@@ -940,8 +949,10 @@ errout:
do {
rcvflg = 0;
+ NET_LOCK_GIANT();
error = soreceive(so, getnam, &auio, mp, NULL, &rcvflg);
- RPCDEBUG("soreceivce returns %d", error);
+ NET_UNLOCK_GIANT();
+ RPCDEBUG("soreceive returns %d", error);
if (error == EWOULDBLOCK && (rep->r_flags & R_SOFTTERM)) {
RPCDEBUG("wouldblock && softerm -> EINTR");
RPC_RETURN(EINTR);
OpenPOWER on IntegriCloud