summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2014-01-22 23:51:12 +0000
committermav <mav@FreeBSD.org>2014-01-22 23:51:12 +0000
commit695b5b9179f2f608ff6042914c460cc75dc11519 (patch)
tree5419eeab7a2baed05f1ecc4daeba3a78189fa04b
parentec416d0ab84b2e916ae2498d35cf43ef91370909 (diff)
downloadFreeBSD-src-695b5b9179f2f608ff6042914c460cc75dc11519.zip
FreeBSD-src-695b5b9179f2f608ff6042914c460cc75dc11519.tar.gz
MFC r260036:
Introduce xprt_inactive_self() -- variant for use when sure that port is assigned to thread. For example, withing receive handlers. In that case the function reduces to single assignment and can avoid locking.
-rw-r--r--sys/rpc/svc.c13
-rw-r--r--sys/rpc/svc.h1
-rw-r--r--sys/rpc/svc_dg.c8
-rw-r--r--sys/rpc/svc_vc.c14
4 files changed, 25 insertions, 11 deletions
diff --git a/sys/rpc/svc.c b/sys/rpc/svc.c
index 96d011a..f63300d 100644
--- a/sys/rpc/svc.c
+++ b/sys/rpc/svc.c
@@ -406,6 +406,19 @@ xprt_inactive(SVCXPRT *xprt)
}
/*
+ * Variant of xprt_inactive() for use only when sure that port is
+ * assigned to thread. For example, withing receive handlers.
+ */
+void
+xprt_inactive_self(SVCXPRT *xprt)
+{
+
+ KASSERT(xprt->xp_thread != NULL,
+ ("xprt_inactive_self(%p) with NULL xp_thread", xprt));
+ xprt->xp_active = FALSE;
+}
+
+/*
* Add a service program to the callout list.
* The dispatch routine will be called when a rpc request for this
* program number comes in.
diff --git a/sys/rpc/svc.h b/sys/rpc/svc.h
index 0b2884f..051ebfb 100644
--- a/sys/rpc/svc.h
+++ b/sys/rpc/svc.h
@@ -523,6 +523,7 @@ __BEGIN_DECLS
extern void xprt_active(SVCXPRT *);
extern void xprt_inactive(SVCXPRT *);
extern void xprt_inactive_locked(SVCXPRT *);
+extern void xprt_inactive_self(SVCXPRT *);
__END_DECLS
#endif
diff --git a/sys/rpc/svc_dg.c b/sys/rpc/svc_dg.c
index 861c26e..79f8429 100644
--- a/sys/rpc/svc_dg.c
+++ b/sys/rpc/svc_dg.c
@@ -196,10 +196,10 @@ svc_dg_recv(SVCXPRT *xprt, struct rpc_msg *msg,
* from racing the upcall after our soreadable() call
* returns false.
*/
- mtx_lock(&xprt->xp_pool->sp_lock);
+ SOCKBUF_LOCK(&xprt->xp_socket->so_rcv);
if (!soreadable(xprt->xp_socket))
- xprt_inactive_locked(xprt);
- mtx_unlock(&xprt->xp_pool->sp_lock);
+ xprt_inactive_self(xprt);
+ SOCKBUF_UNLOCK(&xprt->xp_socket->so_rcv);
sx_xunlock(&xprt->xp_lock);
return (FALSE);
}
@@ -208,7 +208,7 @@ svc_dg_recv(SVCXPRT *xprt, struct rpc_msg *msg,
SOCKBUF_LOCK(&xprt->xp_socket->so_rcv);
soupcall_clear(xprt->xp_socket, SO_RCV);
SOCKBUF_UNLOCK(&xprt->xp_socket->so_rcv);
- xprt_inactive(xprt);
+ xprt_inactive_self(xprt);
sx_xunlock(&xprt->xp_lock);
return (FALSE);
}
diff --git a/sys/rpc/svc_vc.c b/sys/rpc/svc_vc.c
index f9ff0e6..3140915 100644
--- a/sys/rpc/svc_vc.c
+++ b/sys/rpc/svc_vc.c
@@ -385,7 +385,7 @@ svc_vc_rendezvous_recv(SVCXPRT *xprt, struct rpc_msg *msg,
*/
ACCEPT_LOCK();
if (TAILQ_EMPTY(&xprt->xp_socket->so_comp))
- xprt_inactive(xprt);
+ xprt_inactive_self(xprt);
ACCEPT_UNLOCK();
sx_xunlock(&xprt->xp_lock);
return (FALSE);
@@ -398,7 +398,7 @@ svc_vc_rendezvous_recv(SVCXPRT *xprt, struct rpc_msg *msg,
soupcall_clear(xprt->xp_socket, SO_RCV);
}
SOCKBUF_UNLOCK(&xprt->xp_socket->so_rcv);
- xprt_inactive(xprt);
+ xprt_inactive_self(xprt);
sx_xunlock(&xprt->xp_lock);
return (FALSE);
}
@@ -667,7 +667,7 @@ svc_vc_recv(SVCXPRT *xprt, struct rpc_msg *msg,
if (cd->mreq == NULL || cd->resid != 0) {
SOCKBUF_LOCK(&so->so_rcv);
if (!soreadable(so))
- xprt_inactive(xprt);
+ xprt_inactive_self(xprt);
SOCKBUF_UNLOCK(&so->so_rcv);
}
@@ -709,7 +709,7 @@ svc_vc_recv(SVCXPRT *xprt, struct rpc_msg *msg,
*/
SOCKBUF_LOCK(&so->so_rcv);
if (!soreadable(so))
- xprt_inactive(xprt);
+ xprt_inactive_self(xprt);
SOCKBUF_UNLOCK(&so->so_rcv);
sx_xunlock(&xprt->xp_lock);
return (FALSE);
@@ -722,7 +722,7 @@ svc_vc_recv(SVCXPRT *xprt, struct rpc_msg *msg,
soupcall_clear(so, SO_RCV);
}
SOCKBUF_UNLOCK(&so->so_rcv);
- xprt_inactive(xprt);
+ xprt_inactive_self(xprt);
cd->strm_stat = XPRT_DIED;
sx_xunlock(&xprt->xp_lock);
return (FALSE);
@@ -732,7 +732,7 @@ svc_vc_recv(SVCXPRT *xprt, struct rpc_msg *msg,
/*
* EOF - the other end has closed the socket.
*/
- xprt_inactive(xprt);
+ xprt_inactive_self(xprt);
cd->strm_stat = XPRT_DIED;
sx_xunlock(&xprt->xp_lock);
return (FALSE);
@@ -763,7 +763,7 @@ svc_vc_backchannel_recv(SVCXPRT *xprt, struct rpc_msg *msg,
mtx_lock(&ct->ct_lock);
m = cd->mreq;
if (m == NULL) {
- xprt_inactive(xprt);
+ xprt_inactive_self(xprt);
mtx_unlock(&ct->ct_lock);
sx_xunlock(&xprt->xp_lock);
return (FALSE);
OpenPOWER on IntegriCloud