summaryrefslogtreecommitdiffstats
path: root/ctdb/server
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2009-12-18 14:13:09 +1030
committerRonnie Sahlberg <ronniesahlberg@gmail.com>2009-12-18 14:48:41 +1100
commit565b2cda11690550560bdd41fcfad826d1ae4a3d (patch)
treebd78bc954ff0dd7a84346b99451b922416cdea2b /ctdb/server
parente757b7c4bf1666169e58dda69ff286ccdb4372db (diff)
downloadsamba-565b2cda11690550560bdd41fcfad826d1ae4a3d.tar.gz
samba-565b2cda11690550560bdd41fcfad826d1ae4a3d.tar.xz
samba-565b2cda11690550560bdd41fcfad826d1ae4a3d.zip
eventscript: fix bug when script is aborted
Another corner case when we terminate running monitor scripts to run something else: logging can flush the output and we write to a NULL pointer. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (This used to be ctdb commit eb22c34bccc8a04fcf63efa2bc48d9788709382e)
Diffstat (limited to 'ctdb/server')
-rw-r--r--ctdb/server/eventscript.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/ctdb/server/eventscript.c b/ctdb/server/eventscript.c
index 481b47a97a..9ce9cee484 100644
--- a/ctdb/server/eventscript.c
+++ b/ctdb/server/eventscript.c
@@ -87,9 +87,16 @@ static void log_event_script_output(const char *str, uint16_t len, void *p)
{
struct ctdb_event_script_state *state
= talloc_get_type(p, struct ctdb_event_script_state);
- struct ctdb_script_wire *current = get_current_script(state);
+ struct ctdb_script_wire *current;
unsigned int slen, min;
+ /* We may have been aborted to run something else. Discard */
+ if (state->scripts == NULL) {
+ return;
+ }
+
+ current = get_current_script(state);
+
/* Append, but don't overfill buffer. It starts zero-filled. */
slen = strlen(current->output);
min = MIN(len, sizeof(current->output) - slen - 1);