]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-recovery: Use single char ASCII numbers for status from child
authorMartin Schwenke <martin@meltin.net>
Fri, 1 Apr 2016 03:35:15 +0000 (14:35 +1100)
committerAmitay Isaacs <amitay@samba.org>
Thu, 28 Apr 2016 07:39:16 +0000 (09:39 +0200)
  '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 <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ctdb_recover.c

index 81c152b63a7b62d973ef93c96b645f67a6116c85..a355f9f744c60b056e64f8795fd327b4d7a65bd0 100644 (file)
@@ -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);