diff options
author | jhb <jhb@FreeBSD.org> | 2000-11-14 18:22:59 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2000-11-14 18:22:59 +0000 |
commit | c87f1c4961bb04662b7e6266a96d44a61c9386f9 (patch) | |
tree | bc41c75cc0b076b226ad7e5d44eb6d281f7951b5 | |
parent | 4e5cd1b9b82b74a0d9a00fed11ec31078d618515 (diff) | |
download | FreeBSD-src-c87f1c4961bb04662b7e6266a96d44a61c9386f9.zip FreeBSD-src-c87f1c4961bb04662b7e6266a96d44a61c9386f9.tar.gz |
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
-rw-r--r-- | sys/sys/eventhandler.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/sys/eventhandler.h b/sys/sys/eventhandler.h index c41acb5..4a1e01a 100644 --- a/sys/sys/eventhandler.h +++ b/sys/sys/eventhandler.h @@ -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) |