->monitor_context is NULL when monitoring is disabled.
authorRonnie Sahlberg <sahlberg@ronnie>
Thu, 29 Nov 2007 22:02:37 +0000 (09:02 +1100)
committerRonnie Sahlberg <sahlberg@ronnie>
Thu, 29 Nov 2007 22:02:37 +0000 (09:02 +1100)
Check whether monitoring is enabled or not before creating new events
and log why the event is not set up othervise

server/ctdb_monitor.c

index 9a3986711ab2dedfec79a406650733f0c3aa117c..ce172fa3452876b16ce6b3874be6c63fadded6a4 100644 (file)
@@ -110,9 +110,15 @@ static void ctdb_health_callback(struct ctdb_context *ctdb, int status, void *p)
                next_interval = ctdb->tunable.monitor_interval;
        }
 
-       event_add_timed(ctdb->ev, ctdb->monitor_context, 
-                       timeval_current_ofs(next_interval, 0), 
-                       ctdb_check_health, ctdb);
+       if (ctdb->monitor_context == NULL) {
+               DEBUG(0,(__location__ " monitoring was disabled while running"
+                       " healthcheck. Health checks postphoned until"
+                       " monitoring is re-enabled.\n"));
+       } else {
+               event_add_timed(ctdb->ev, ctdb->monitor_context, 
+                               timeval_current_ofs(next_interval, 0), 
+                               ctdb_check_health, ctdb);
+       }
 
        if (c.old_flags == node->flags) {
                return;
@@ -143,13 +149,27 @@ static void ctdb_startup_callback(struct ctdb_context *ctdb, int status, void *p
        }
 
        if (ctdb->done_startup) {
-               event_add_timed(ctdb->ev, ctdb->monitor_context, 
-                               timeval_zero(),
-                               ctdb_check_health, ctdb);
+               if (ctdb->monitor_context == NULL) {
+                       DEBUG(0,(__location__ " monitoring was disabled while "
+                               "running startup event. "
+                               "startup event postphoned until "
+                               "monitoring is re-enabled.\n"));
+               } else {
+                       event_add_timed(ctdb->ev, ctdb->monitor_context, 
+                                       timeval_zero(),
+                                       ctdb_check_health, ctdb);
+               }
        } else {
-               event_add_timed(ctdb->ev, ctdb->monitor_context, 
-                               timeval_current_ofs(ctdb->tunable.monitor_interval, 0), 
-                               ctdb_check_health, ctdb);
+               if (ctdb->monitor_context == NULL) {
+                       DEBUG(0,(__location__ " monitoring was disabled while "
+                               "running startup event. "
+                               "Health cheack postphoned until "
+                               "monitoring is re-enabled.\n"));
+               } else {
+                       event_add_timed(ctdb->ev, ctdb->monitor_context, 
+                                       timeval_current_ofs(ctdb->tunable.monitor_interval, 0),
+                                       ctdb_check_health, ctdb);
+               }
        }
 
 }