eventscript: remove call name from state->options
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 24 Nov 2009 00:52:46 +0000 (11:22 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 24 Nov 2009 00:52:46 +0000 (11:22 +1030)
Finally, we remove the call name (eg. "monitor" or "start") from the
options field of the struct: it now contains only extra options.

This is clearer, and mainly involves adding some %s to debug statements.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
server/eventscript.c

index 7e97583d5f23c72c36d5279c85521b7cc3110c25..6f3f7937efbdc57717bbbe5fdef8192cf094402a 100644 (file)
@@ -533,9 +533,9 @@ static int ctdb_run_event_script(struct ctdb_context *ctdb,
                                        ctdb->event_script_dir,
                                        current->name, "status");
                } else {
-                       cmdstr = talloc_asprintf(tmp_ctx, "%s/%s %s", 
+                       cmdstr = talloc_asprintf(tmp_ctx, "%s/%s %s %s",
                                        ctdb->event_script_dir,
-                                       current->name, options);
+                                       current->name, call_names[call], options);
                }
                CTDB_NO_MEMORY(ctdb, cmdstr);
 
@@ -629,7 +629,8 @@ static void ctdb_event_script_handler(struct event_context *ev, struct fd_event
                state->cb_status = -2;
        }
 
-       DEBUG(DEBUG_INFO,(__location__ " Eventscript %s finished with state %d\n", state->options, state->cb_status));
+       DEBUG(DEBUG_INFO,(__location__ " Eventscript %s %s finished with state %d\n",
+                         call_names[state->call], state->options, state->cb_status));
 
        state->child = 0;
        ctdb->event_script_timeouts = 0;
@@ -658,7 +659,8 @@ static void ctdb_event_script_timeout(struct event_context *ev, struct timed_eve
        struct ctdb_event_script_state *state = talloc_get_type(p, struct ctdb_event_script_state);
        struct ctdb_context *ctdb = state->ctdb;
 
-       DEBUG(DEBUG_ERR,("Event script timed out : %s count : %u  pid : %d\n", state->options, ctdb->event_script_timeouts, state->child));
+       DEBUG(DEBUG_ERR,("Event script timed out : %s %s count : %u  pid : %d\n",
+                        call_names[state->call], state->options, ctdb->event_script_timeouts, state->child));
 
        if (kill(state->child, 0) != 0) {
                DEBUG(DEBUG_ERR,("Event script child process already dead, errno %s(%d)\n", strerror(errno), errno));
@@ -795,9 +797,7 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
        state->callback = callback;
        state->private_data = private_data;
        state->call = call;
-       state->options = talloc_asprintf(state, "%s ", call_names[call]);
-       if (state->options)
-               state->options = talloc_vasprintf_append(discard_const_p(char, state->options), fmt, ap);
+       state->options = talloc_vasprintf(state, fmt, ap);
        state->timeout = timeval_set(ctdb->tunable.script_timeout, 0);
        if (state->options == NULL) {
                DEBUG(DEBUG_ERR, (__location__ " could not allocate state->options\n"));
@@ -805,7 +805,8 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
                return -1;
        }
 
-       DEBUG(DEBUG_INFO,(__location__ " Starting eventscript %s\n", state->options));
+       DEBUG(DEBUG_INFO,(__location__ " Starting eventscript %s %s\n",
+                         call_names[state->call], state->options));
        
        ret = pipe(state->fd);
        if (ret != 0) {
@@ -848,7 +849,8 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
        if (!timeval_is_zero(&state->timeout)) {
                event_add_timed(ctdb->ev, state, timeval_current_ofs(state->timeout.tv_sec, state->timeout.tv_usec), ctdb_event_script_timeout, state);
        } else {
-               DEBUG(DEBUG_ERR, (__location__ " eventscript %s called with no timeout\n", state->options));
+               DEBUG(DEBUG_ERR, (__location__ " eventscript %s %s called with no timeout\n",
+                                 call_names[state->call], state->options));
        }
 
        return 0;