mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-25 18:59:33 +03:00
Condition variable usage, zevent_cv
The following incorrect usage of cv_broadcast() was caught by code inspection. The cv_broadcast() function must be called under the associated mutex to preventing racing with cv_wait(). Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
This commit is contained in:
parent
6cb7ab069d
commit
99db9bfde7
@ -481,14 +481,13 @@ zfs_zevent_drain_all(int *count)
|
||||
static void
|
||||
zfs_zevent_insert(zevent_t *ev)
|
||||
{
|
||||
mutex_enter(&zevent_lock);
|
||||
ASSERT(MUTEX_HELD(&zevent_lock));
|
||||
list_insert_head(&zevent_list, ev);
|
||||
|
||||
if (zevent_len_cur >= zfs_zevent_len_max)
|
||||
zfs_zevent_drain(list_tail(&zevent_list));
|
||||
else
|
||||
zevent_len_cur++;
|
||||
|
||||
mutex_exit(&zevent_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -528,8 +527,11 @@ zfs_zevent_post(nvlist_t *nvl, nvlist_t *detector, zevent_cb_t *cb)
|
||||
ev->ev_nvl = nvl;
|
||||
ev->ev_detector = detector;
|
||||
ev->ev_cb = cb;
|
||||
|
||||
mutex_enter(&zevent_lock);
|
||||
zfs_zevent_insert(ev);
|
||||
cv_broadcast(&zevent_cv);
|
||||
mutex_exit(&zevent_lock);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -1520,9 +1522,10 @@ fm_fini(void)
|
||||
int count;
|
||||
|
||||
zfs_zevent_drain_all(&count);
|
||||
cv_broadcast(&zevent_cv);
|
||||
|
||||
mutex_enter(&zevent_lock);
|
||||
cv_broadcast(&zevent_cv);
|
||||
|
||||
zevent_flags |= ZEVENT_SHUTDOWN;
|
||||
while (zevent_waiters > 0) {
|
||||
mutex_exit(&zevent_lock);
|
||||
|
Loading…
Reference in New Issue
Block a user