src/virt.c: Decouple persistent notifications from refreshInterval
authorAntoine Naud <antoinex.naud@intel.com>
Wed, 21 Mar 2018 08:51:42 +0000 (08:51 +0000)
committerRadoslaw Jablonski <radoslawx.jablonski@intel.com>
Thu, 19 Apr 2018 12:03:40 +0000 (13:03 +0100)
When persistentNotification is true, if refreshInterval value is larger than
(read) Interval, the notifications are not issued every read interval as should
be. The fix consist in decoupling persistent notifications from refreshInterval.

Change-Id: I157554a360510c21ffa631430446afd57b99dfab
Signed-off-by: Antoine Naud <antoinex.naud@intel.com>
src/virt.c

index 2899177..e01efd3 100644 (file)
@@ -1990,13 +1990,6 @@ static int lv_read(user_data_t *ud) {
   /* Need to refresh domain or device lists? */
   if ((last_refresh == (time_t)0) ||
       ((interval > 0) && ((last_refresh + interval) <= t))) {
   /* Need to refresh domain or device lists? */
   if ((last_refresh == (time_t)0) ||
       ((interval > 0) && ((last_refresh + interval) <= t))) {
-    if (inst->id == 0 && persistent_notification) {
-      int status = persistent_domains_state_notification();
-      if (status != 0)
-        DEBUG(PLUGIN_NAME " plugin: persistent_domains_state_notifications "
-                          "returned with status %i",
-              status);
-    }
     if (refresh_lists(inst) != 0) {
       if (inst->id == 0) {
         if (!persistent_notification)
     if (refresh_lists(inst) != 0) {
       if (inst->id == 0) {
         if (!persistent_notification)
@@ -2008,6 +2001,15 @@ static int lv_read(user_data_t *ud) {
     last_refresh = t;
   }
 
     last_refresh = t;
   }
 
+  /* persistent domains state notifications are handled by instance 0 */
+  if (inst->id == 0 && persistent_notification) {
+    int status = persistent_domains_state_notification();
+    if (status != 0)
+      DEBUG(PLUGIN_NAME " plugin: persistent_domains_state_notifications "
+                        "returned with status %i",
+            status);
+  }
+
 #if COLLECT_DEBUG
   for (int i = 0; i < state->nr_domains; ++i)
     DEBUG(PLUGIN_NAME " plugin: domain %s",
 #if COLLECT_DEBUG
   for (int i = 0; i < state->nr_domains; ++i)
     DEBUG(PLUGIN_NAME " plugin: domain %s",