From 3d9f38d578f2750c746f9dd136227ca23b607aa8 Mon Sep 17 00:00:00 2001 From: rwatson Date: Thu, 19 Aug 2004 01:45:16 +0000 Subject: Add UNP_UNLOCK_ASSERT() to asser that the UNIX domain socket subsystem lock is not held. Rather than annotating that the lock is released after calls to unp_detach() with a comment, annotate with an assertion. Assert that the UNIX domain socket subsystem lock is not held when unp_externalize() and unp_internalize() are called. --- sys/kern/uipc_usrreq.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index 4075f8a..9f41320 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -108,6 +108,7 @@ static struct mtx unp_mtx; #define UNP_LOCK() mtx_lock(&unp_mtx) #define UNP_UNLOCK() mtx_unlock(&unp_mtx) #define UNP_LOCK_ASSERT() mtx_assert(&unp_mtx, MA_OWNED) +#define UNP_UNLOCK_ASSERT() mtx_assert(&unp_mtx, MA_NOTOWNED) static int unp_attach(struct socket *); static void unp_detach(struct unpcb *); @@ -137,7 +138,8 @@ uipc_abort(struct socket *so) return (EINVAL); } unp_drop(unp, ECONNABORTED); - unp_detach(unp); /* NB: unlocks */ + unp_detach(unp); + UNP_UNLOCK_ASSERT(); SOCK_LOCK(so); sotryfree(so); return (0); @@ -248,7 +250,8 @@ uipc_detach(struct socket *so) UNP_UNLOCK(); return (EINVAL); } - unp_detach(unp); /* NB: unlocks unp */ + unp_detach(unp); + UNP_UNLOCK_ASSERT(); return (0); } @@ -1041,6 +1044,7 @@ unp_abort(unp) { unp_detach(unp); + UNP_UNLOCK_ASSERT(); } #endif @@ -1232,6 +1236,8 @@ unp_externalize(control, controlp) int f; u_int newlen; + UNP_UNLOCK_ASSERT(); + error = 0; if (controlp != NULL) /* controlp == NULL => free control messages */ *controlp = NULL; @@ -1358,6 +1364,8 @@ unp_internalize(controlp, td) int error, oldfds; u_int newlen; + UNP_UNLOCK_ASSERT(); + error = 0; *controlp = NULL; -- cgit v1.1