From bca2ec16a6d2cd9fc9e287e8e516792c63ecbf34 Mon Sep 17 00:00:00 2001 From: Rick Macklem Date: Sun, 7 Jun 2009 20:38:41 +0000 Subject: [PATCH] Add a check to xprt_unregister() to catch the case where another thread has already unregistered the structure. Also add a KASSERT() to xprt_unregister_locked() to check that the structure hasn't already been unregistered. Reviewed by: jhb Tested by: pho Approved by: kib (mentor) --- sys/rpc/svc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sys/rpc/svc.c b/sys/rpc/svc.c index 5db4c565d32..8c3bd2c9629 100644 --- a/sys/rpc/svc.c +++ b/sys/rpc/svc.c @@ -293,6 +293,8 @@ xprt_unregister_locked(SVCXPRT *xprt) { SVCPOOL *pool = xprt->xp_pool; + KASSERT(xprt->xp_registered == TRUE, + ("xprt_unregister_locked: not registered")); if (xprt->xp_active) { TAILQ_REMOVE(&pool->sp_active, xprt, xp_alink); xprt->xp_active = FALSE; @@ -307,6 +309,11 @@ xprt_unregister(SVCXPRT *xprt) SVCPOOL *pool = xprt->xp_pool; mtx_lock(&pool->sp_lock); + if (xprt->xp_registered == FALSE) { + /* Already unregistered by another thread */ + mtx_unlock(&pool->sp_lock); + return; + } xprt_unregister_locked(xprt); mtx_unlock(&pool->sp_lock);