aboutsummaryrefslogtreecommitdiffstats
path: root/module/zfs/fm.c
diff options
context:
space:
mode:
Diffstat (limited to 'module/zfs/fm.c')
-rw-r--r--module/zfs/fm.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/module/zfs/fm.c b/module/zfs/fm.c
index 4986a3fa2..6d2166a09 100644
--- a/module/zfs/fm.c
+++ b/module/zfs/fm.c
@@ -665,25 +665,37 @@ out:
return (error);
}
+/*
+ * Wait in an interruptible state for any new events.
+ */
int
zfs_zevent_wait(zfs_zevent_t *ze)
{
- int error = 0;
+ int error = EAGAIN;
mutex_enter(&zevent_lock);
+ zevent_waiters++;
- if (zevent_flags & ZEVENT_SHUTDOWN) {
- error = ESHUTDOWN;
- goto out;
- }
+ while (error == EAGAIN) {
+ if (zevent_flags & ZEVENT_SHUTDOWN) {
+ error = SET_ERROR(ESHUTDOWN);
+ break;
+ }
- zevent_waiters++;
- cv_wait_sig(&zevent_cv, &zevent_lock);
- if (issig(JUSTLOOKING))
- error = EINTR;
+ error = cv_timedwait_sig(&zevent_cv, &zevent_lock,
+ ddi_get_lbolt() + MSEC_TO_TICK(10));
+ if (signal_pending(current)) {
+ error = SET_ERROR(EINTR);
+ break;
+ } else if (!list_is_empty(&zevent_list)) {
+ error = 0;
+ continue;
+ } else {
+ error = EAGAIN;
+ }
+ }
zevent_waiters--;
-out:
mutex_exit(&zevent_lock);
return (error);