From ec41a9a1bdd16c0fa92333a5921bd6078a013a22 Mon Sep 17 00:00:00 2001 From: Lawrence Stewart Date: Mon, 17 Jun 2013 09:49:07 +0000 Subject: [PATCH] The fix committed in r250951 replaced the reported panic with a deadlock... gold star for me. EVENTHANDLER_DEREGISTER() attempts to acquire the lock which is held by the event handler framework while executing event handler functions, leading to deadlock. Move EVENTHANDLER_DEREGISTER() to alq_load_handler() and thus deregister the ALQ shutdown_pre_sync handler at module unload time, which takes care of the originally reported panic and fixes the deadlock introduced in r250951. Reported by: Luiz Otavio O Souza MFC after: 3 days X-MFC with: 250951 --- sys/kern/kern_alq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_alq.c b/sys/kern/kern_alq.c index daf4e4644667..1e6fcf7d1455 100644 --- a/sys/kern/kern_alq.c +++ b/sys/kern/kern_alq.c @@ -229,8 +229,6 @@ ald_shutdown(void *arg, int howto) { struct alq *alq; - EVENTHANDLER_DEREGISTER(shutdown_pre_sync, alq_eventhandler_tag); - ALD_LOCK(); /* Ensure no new queues can be created. */ @@ -938,6 +936,8 @@ alq_load_handler(module_t mod, int what, void *arg) if (LIST_FIRST(&ald_queues) == NULL) { ald_shutingdown = 1; ALD_UNLOCK(); + EVENTHANDLER_DEREGISTER(shutdown_pre_sync, + alq_eventhandler_tag); ald_shutdown(NULL, 0); mtx_destroy(&ald_mtx); } else {