mirror of
https://github.com/samba-team/samba.git
synced 2025-03-24 10:50:22 +03:00
create a separate context for non-monitor eventscripts so they dont collide
(This used to be ctdb commit 325de818f88f339a16dc4544e899a2d735933c44)
This commit is contained in:
parent
f8a8c0d6e4
commit
d379b30182
@ -452,6 +452,7 @@ struct ctdb_context {
|
||||
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 */
|
||||
TALLOC_CTX *last_monitor_ctx;
|
||||
TALLOC_CTX *event_script_ctx; /* non-monitoring events */
|
||||
TALLOC_CTX *banning_ctx;
|
||||
};
|
||||
|
||||
|
@ -736,7 +736,7 @@ static void ctdb_event_script_timeout(struct event_context *ev, struct timed_eve
|
||||
}
|
||||
}
|
||||
|
||||
if (monitoring_status != NULL) {
|
||||
if ((!strcmp(options, "monitor")) && (monitoring_status != NULL)) {
|
||||
struct ctdb_monitor_script_status *script;
|
||||
|
||||
script = monitoring_status->scripts;
|
||||
@ -788,11 +788,19 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
|
||||
struct ctdb_event_script_state *state;
|
||||
int ret;
|
||||
|
||||
if (ctdb->script_monitor_ctx != NULL) {
|
||||
talloc_free(ctdb->script_monitor_ctx);
|
||||
ctdb->script_monitor_ctx = NULL;
|
||||
if (!strcmp(fmt, "monitor")) {
|
||||
if (ctdb->script_monitor_ctx != NULL) {
|
||||
talloc_free(ctdb->script_monitor_ctx);
|
||||
ctdb->script_monitor_ctx = NULL;
|
||||
}
|
||||
monitoring_status = talloc_zero(ctdb, struct ctdb_monitor_status);
|
||||
} else {
|
||||
if (ctdb->event_script_ctx == NULL) {
|
||||
ctdb->event_script_ctx = talloc_zero(ctdb, struct ctdb_monitor_status);
|
||||
}
|
||||
monitoring_status = ctdb->event_script_ctx;
|
||||
}
|
||||
monitoring_status = talloc_zero(ctdb, struct ctdb_monitor_status);
|
||||
|
||||
if (monitoring_status == NULL) {
|
||||
DEBUG(DEBUG_ERR, (__location__ " ERROR: Failed to talloc script_monitoring context\n"));
|
||||
return -1;
|
||||
@ -801,7 +809,6 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
|
||||
state = talloc(monitoring_status, struct ctdb_event_script_state);
|
||||
if (state == NULL) {
|
||||
DEBUG(DEBUG_ERR,(__location__ " could not allocate state\n"));
|
||||
talloc_free(monitoring_status);
|
||||
return -1;
|
||||
}
|
||||
monitoring_status->state = state;
|
||||
@ -814,7 +821,7 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
|
||||
state->te = NULL;
|
||||
if (state->options == NULL) {
|
||||
DEBUG(DEBUG_ERR, (__location__ " could not allocate state->options\n"));
|
||||
talloc_free(monitoring_status);
|
||||
talloc_free(state);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -822,7 +829,7 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
|
||||
|
||||
ret = pipe(state->fd);
|
||||
if (ret != 0) {
|
||||
talloc_free(monitoring_status);
|
||||
talloc_free(state);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -831,7 +838,7 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
|
||||
if (state->child == (pid_t)-1) {
|
||||
close(state->fd[0]);
|
||||
close(state->fd[1]);
|
||||
talloc_free(monitoring_status);
|
||||
talloc_free(state);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -850,7 +857,11 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
|
||||
}
|
||||
|
||||
talloc_set_destructor(state, event_script_destructor);
|
||||
ctdb->script_monitor_ctx = monitoring_status;
|
||||
if (!strcmp(fmt, "monitor")) {
|
||||
ctdb->script_monitor_ctx = monitoring_status;
|
||||
} else {
|
||||
ctdb->event_script_ctx = monitoring_status;
|
||||
}
|
||||
|
||||
close(state->fd[1]);
|
||||
set_close_on_exec(state->fd[0]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user