diff options
author | Martin Schwenke <martin@meltin.net> | 2014-12-09 13:40:23 +1100 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2015-01-09 02:03:40 +0100 |
commit | 6f1ac7af0f87d85402d708231e45a69713bba026 (patch) | |
tree | bf4941a49f4b146b2ef1733d43fd97a1af10c9db /ctdb | |
parent | 4638010abb116aed0c180207aaa11475277aecb7 (diff) | |
download | samba-6f1ac7af0f87d85402d708231e45a69713bba026.tar.gz samba-6f1ac7af0f87d85402d708231e45a69713bba026.tar.xz samba-6f1ac7af0f87d85402d708231e45a69713bba026.zip |
ctdb-daemon: Handle out-of-memory when setting recovery lock file
Log a message when the reclock file actually changes and avoid a
memory allocation when it doesn't change.
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'ctdb')
-rw-r--r-- | ctdb/server/ctdb_control.c | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/ctdb/server/ctdb_control.c b/ctdb/server/ctdb_control.c index 49bc9863a9..9d835e8d59 100644 --- a/ctdb/server/ctdb_control.c +++ b/ctdb/server/ctdb_control.c @@ -519,17 +519,35 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb, outdata->dsize = strlen(ctdb->recovery_lock_file) + 1; } return 0; - case CTDB_CONTROL_SET_RECLOCK_FILE: - ctdb->tunable.verify_recovery_lock = 0; - if (ctdb->recovery_lock_file != NULL) { - talloc_free(ctdb->recovery_lock_file); - ctdb->recovery_lock_file = NULL; + case CTDB_CONTROL_SET_RECLOCK_FILE: { + char *t; + + if (indata.dsize == 0) { + TALLOC_FREE(ctdb->recovery_lock_file); + return 0; + } + + /* Return silent success if unchanged. Recovery + * master updates all nodes on each recovery - we + * don't need the extra memory allocation or log + * message each time. */ + if (strcmp(discard_const(indata.dptr), + ctdb->recovery_lock_file) == 0) { + return 0; } - if (indata.dsize > 0) { - ctdb->recovery_lock_file = talloc_strdup(ctdb, discard_const(indata.dptr)); - ctdb->tunable.verify_recovery_lock = 1; + + t = talloc_strdup(ctdb, discard_const(indata.dptr)); + if (t == NULL) { + DEBUG(DEBUG_ERR, ("Out of memory in SET_RECLOCK_FILE\n")); + return -1; } + + talloc_free(ctdb->recovery_lock_file); + ctdb->recovery_lock_file = t; + DEBUG(DEBUG_NOTICE, ("Updated recovery lock file to %s\n", t)); + return 0; + } case CTDB_CONTROL_STOP_NODE: CHECK_CONTROL_DATA_SIZE(0); |