From 02eb000f5145aa60578b4591053bff9a797e64cc Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Wed, 21 Oct 2015 20:52:29 +0200 Subject: [PATCH] dmeventd: use dm_hold_control_dev Need here to keep control device opened while there is 'any' dso plugin loaded - otherwise there would a race closing controlfd inside lvm2 plugin while some other monitoring thread would tried to execute another WAITEVENT task. --- WHATS_NEW_DM | 1 + daemons/dmeventd/dmeventd.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM index 2b87e4bf8..000bddd67 100644 --- a/WHATS_NEW_DM +++ b/WHATS_NEW_DM @@ -1,5 +1,6 @@ Version 1.02.110 - ====================================== + Dmeventd closes control device when no device is monitored. Thin plugin for dmeventd improved percentage usage. Snapshot plugin for dmeventd improved percentage usage. Add dm_hold_control_dev to allow holding of control device open. diff --git a/daemons/dmeventd/dmeventd.c b/daemons/dmeventd/dmeventd.c index 69fe3930c..885aa9de4 100644 --- a/daemons/dmeventd/dmeventd.c +++ b/daemons/dmeventd/dmeventd.c @@ -282,6 +282,13 @@ static void _lib_put(struct dso_data *data) dlclose(data->dso_handle); UNLINK_DSO(data); _free_dso_data(data); + + /* Close control device if there is no plugin in-use */ + if (dm_list_empty(&_dso_registry)) { + DEBUGLOG("Unholding control device."); + dm_hold_control_dev(0); + dm_lib_release(); + } } } @@ -344,6 +351,12 @@ static struct dso_data *_load_dso(struct message_data *data) goto_bad; } + /* Keep control device open until last user closes */ + if (dm_list_empty(&_dso_registry)) { + DEBUGLOG("Holding control device open."); + dm_hold_control_dev(1); + } + /* * Keep handle to close the library once * we've got no references to it any more.