dont reset the event script context everytime we start a new "ctdb eventscript ..."
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 19 Nov 2009 00:03:51 +0000 (11:03 +1100)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 19 Nov 2009 00:03:51 +0000 (11:03 +1100)
command.
Use the existing context used for non-monitor events

Multiple concurrent uses of "ctdb eventscript ..." could otherwise lead to a SEGV

include/ctdb_private.h
server/eventscript.c

index 674b0aca6fd717cea076b1b2557a9dcf047b58b9..f937ef40a3658925f0fc97ea616d29f40f733b37 100644 (file)
@@ -448,7 +448,6 @@ struct ctdb_context {
        int start_as_disabled;
        int start_as_stopped;
        uint32_t event_script_timeouts; /* counting how many consecutive times an eventscript has timedout */
-       TALLOC_CTX *eventscripts_ctx; /* a context to hold data for the RUN_EVENTSCRIPTS control */
        uint32_t *recd_ping_count;
        TALLOC_CTX *release_ips_ctx; /* a context used to automatically drop all IPs if we fail to recover the node */
        TALLOC_CTX *script_monitor_ctx; /* a context where we store results while running the monitor event */
index 7ad66c6c6d00f2cb7032a4d6751233b1d1a400d9..3514c3218256860b19e3dfb5528151e0e30f5989 100644 (file)
@@ -952,7 +952,7 @@ struct eventscript_callback_state {
 };
 
 /*
-  called when takeip event finishes
+  called when a forced eventscript run has finished
  */
 static void run_eventscripts_callback(struct ctdb_context *ctdb, int status, 
                                 void *private_data)
@@ -985,14 +985,11 @@ int32_t ctdb_run_eventscripts(struct ctdb_context *ctdb,
        int ret;
        struct eventscript_callback_state *state;
 
-       /* kill off any previous invokations of forced eventscripts */
-       if (ctdb->eventscripts_ctx) {
-               talloc_free(ctdb->eventscripts_ctx);
+       if (ctdb->event_script_ctx == NULL) {
+               ctdb->event_script_ctx = talloc_zero(ctdb, struct ctdb_monitor_status);
        }
-       ctdb->eventscripts_ctx = talloc_new(ctdb);
-       CTDB_NO_MEMORY(ctdb, ctdb->eventscripts_ctx);
 
-       state = talloc(ctdb->eventscripts_ctx, struct eventscript_callback_state);
+       state = talloc(ctdb->event_script_ctx, struct eventscript_callback_state);
        CTDB_NO_MEMORY(ctdb, state);
 
        state->c = talloc_steal(state, c);