Skip to contentSkip to conversation

master - dmeventd: handle signal from plugin

PATCH Zdenek Kabelac 1 participant 1 message Oct 22, 2015

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=12aa56d29867b962257d7d2789a661a22c649347
Commit:        12aa56d29867b962257d7d2789a661a22c649347
Parent:        9156c5d0888bf95b79d931682b51fc63c96ba236
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Thu Oct 22 15:48:14 2015 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Thu Oct 22 22:40:07 2015 +0200

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.

---
 WHATS_NEW_DM                |    3 ++-
 daemons/dmeventd/dmeventd.c |   11 +++++++++++
 2 files changed, 13 insertions(+), 1 deletions(-)
WHATS_NEW_DM +2 -1
index 8c27139..8524a6d 100644
@@ -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.
daemons/dmeventd/dmeventd.c +11 -0
index d8c317e..2706ad6 100644
@@ -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();