summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2015-10-22 15:48:14 +0200
committerZdenek Kabelac <zkabelac@redhat.com>2015-10-22 22:40:07 +0200
commit12aa56d29867b962257d7d2789a661a22c649347 (patch)
treebc9b6652d9e3e3039b62d80ef965e6e43d05ef2f
parent9156c5d0888bf95b79d931682b51fc63c96ba236 (diff)
downloadlvm2-12aa56d29867b962257d7d2789a661a22c649347.tar.gz
dmeventd: handle signal from plugin
Add support to unmonitor device when monitor recognizes there is nothing to monitor anymore. TODO: possibly API change with return value could be also used.
-rw-r--r--WHATS_NEW_DM3
-rw-r--r--daemons/dmeventd/dmeventd.c11
2 files changed, 13 insertions, 1 deletions
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 8c271391d..8524a6de8 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,6 +1,7 @@
Version 1.02.110 -
======================================
- New design for thread cooperation in dmeventd.
+ Add support to allow unmonitor device from plugin itself.
+ New design for thread co-operation in dmeventd.
Dmeventd read device status with 'noflush'.
Dmeventd closes control device when no device is monitored.
Thin plugin for dmeventd improved percentage usage.
diff --git a/daemons/dmeventd/dmeventd.c b/daemons/dmeventd/dmeventd.c
index d8c317e8e..2706ad60f 100644
--- a/daemons/dmeventd/dmeventd.c
+++ b/daemons/dmeventd/dmeventd.c
@@ -973,6 +973,17 @@ static void *_monitor_thread(void *arg)
_lock_mutex();
thread->processing = 0;
+
+ /*
+ * Thread can terminate itself from plugin via SIGALRM
+ * Timer thread will not send signal while processing
+ * TODO: maybe worth API change and return value for
+ * _do_process_event() instead of this signal solution
+ */
+ if (sigpending(&pendmask) < 0)
+ log_sys_error("sigpending", "");
+ else if (sigismember(&pendmask, SIGALRM))
+ break;
} else {
_unlock_mutex();