From 14a2330692a4d2e0058e72f9ea8b1c61ed920344 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Fri, 1 Apr 2016 14:35:15 +1100 Subject: ctdb-recovery: Use single char ASCII numbers for status from child '0' = Child took the mutex '1' = Unable to take mutex - contention '2' = Unable to take mutex - timeout '3' = Unable to take mutex - error This is a straightforward API. When the child is generalised to an external helper then this makes it easier for a helper to be, for example, a simple script. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- ctdb/server/ctdb_recover.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'ctdb/server/ctdb_recover.c') diff --git a/ctdb/server/ctdb_recover.c b/ctdb/server/ctdb_recover.c index 81c152b63a7..a355f9f744c 100644 --- a/ctdb/server/ctdb_recover.c +++ b/ctdb/server/ctdb_recover.c @@ -800,7 +800,7 @@ static void cluster_mutex_handler(struct tevent_context *ev, { struct ctdb_cluster_mutex_handle *h= talloc_get_type(private_data, struct ctdb_cluster_mutex_handle); - char c = 0; + char c = '0'; int ret; int status = 0; const char *err = NULL; @@ -813,14 +813,14 @@ static void cluster_mutex_handler(struct tevent_context *ev, ret = sys_read(h->fd[0], &c, 1); if (ret == 1) { - /* Child wrote status. EACCES indicates that it was unable + /* Child wrote status. '1' indicates that it was unable * to take the lock, which is the expected outcome. - * 0 indicates that it was able to take the + * '0' indicates that it was able to take the * lock, which is an error because the recovery daemon * should be holding the lock. */ double l = timeval_elapsed(&h->start_time); - if (c == EACCES) { + if (c == '1') { status = 0; err = NULL; @@ -974,7 +974,7 @@ int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb, } if (h->child == 0) { - char cc = EACCES; + char cc = '1'; close(h->fd[0]); prctl_set_comment("ctdb_recmode"); @@ -986,7 +986,7 @@ int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb, ("ERROR: Daemon able to take recovery lock on \"%s\" during recovery\n", ctdb->recovery_lock_file)); ctdb_recovery_unlock(ctdb); - cc = 0; + cc = '0'; } sys_write(h->fd[1], &cc, 1); -- cgit v1.2.1