From: Zdenek Kabelac Date: Thu, 22 Oct 2015 13:48:14 +0000 (+0200) Subject: dmeventd: handle signal from plugin X-Git-Tag: v2_02_133~76 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=12aa56d29867b962257d7d2789a661a22c649347;p=lvm2.git 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. --- 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();