Only hold the mutex for an eventhandler list while the list is being accessed.

Specifically, don't hold the lock while calling event handlers as a handler
may tsleep() while holding the mutex.

Found by:	witness
This commit is contained in:
John Baldwin 2000-11-14 18:22:59 +00:00
parent b3b01ff362
commit 8204c68ecc

View file

@ -81,14 +81,14 @@ do { \
struct eventhandler_entry *_en; \
\
if (_el->el_flags & EHE_INITTED) { \
mtx_enter(&_el->el_mutex, MTX_DEF); \
while (_ep != NULL) { \
mtx_enter(&_el->el_mutex, MTX_DEF); \
_en = TAILQ_NEXT(_ep, ee_link); \
mtx_exit(&_el->el_mutex, MTX_DEF); \
((struct eventhandler_entry_ ## name *)_ep)->eh_func(_ep->ee_arg , \
## args); \
_ep = _en; \
} \
mtx_exit(&_el->el_mutex, MTX_DEF); \
} \
} while (0)
@ -122,13 +122,15 @@ do { \
(_el->el_flags & EHE_INITTED)) { \
mtx_enter(&_el->el_mutex, MTX_DEF); \
_ep = TAILQ_FIRST(&(_el->el_entries)); \
mtx_exit(&_el->el_mutex, MTX_DEF); \
while (_ep != NULL) { \
mtx_enter(&_el->el_mutex, MTX_DEF); \
_en = TAILQ_NEXT(_ep, ee_link); \
mtx_exit(&_el->el_mutex, MTX_DEF); \
((struct eventhandler_entry_ ## name *)_ep)->eh_func(_ep->ee_arg , \
## args); \
_ep = _en; \
} \
mtx_exit(&_el->el_mutex, MTX_DEF); \
} \
} while (0)