summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 27f2019)
raw | patch | inline | side by side (parent: 27f2019)
author | Francesco Romani <fromani@redhat.com> | |
Mon, 12 Dec 2016 11:05:11 +0000 (12:05 +0100) | ||
committer | Francesco Romani <fromani@redhat.com> | |
Tue, 13 Dec 2016 15:33:49 +0000 (16:33 +0100) |
Only one virt reader instance should take care of connection
handling (connection/disconnection) to avoid races and plugin
data corruption, potentially crashing collectd.
This bug cannot be triggered with instances=1 (default settings).
Signed-off-by: Francesco Romani <fromani@redhat.com>
handling (connection/disconnection) to avoid races and plugin
data corruption, potentially crashing collectd.
This bug cannot be triggered with instances=1 (default settings).
Signed-off-by: Francesco Romani <fromani@redhat.com>
src/virt.c | patch | blob | history |
diff --git a/src/virt.c b/src/virt.c
index 93f9aee30d80bdb2427c3edd86191966326c9c19..471bdd7481873e40173556612ba6d48c7a23b205 100644 (file)
--- a/src/virt.c
+++ b/src/virt.c
return 0;
}
+static void lv_disconnect(void) {
+ if (conn != NULL)
+ virConnectClose(conn);
+ conn = NULL;
+ WARNING(PLUGIN_NAME " plugin: closed connection to libvirt");
+}
+
static int lv_read(user_data_t *ud) {
time_t t;
struct lv_read_instance *inst = NULL;
if ((last_refresh == (time_t)0) ||
((interval > 0) && ((last_refresh + interval) <= t))) {
if (refresh_lists(inst) != 0) {
- if (conn != NULL)
- virConnectClose(conn);
- conn = NULL;
+ if (inst->id == 0)
+ lv_disconnect();
return -1;
}
last_refresh = t;