diff options
author | Martin Schwenke <martin@meltin.net> | 2016-02-17 20:20:03 +1100 |
---|---|---|
committer | Amitay Isaacs <amitay@samba.org> | 2016-04-28 09:39:17 +0200 |
commit | bcb838ba1e5414bb6162fdb0b30f3adc8ccef932 (patch) | |
tree | b030a5de00bcd3fa78f955037ac8d5bcc5428d8f /ctdb/server/ctdb_recover.c | |
parent | df99d9e2739eb8e5448bc9cfdf3c469d396dd3e3 (diff) | |
download | samba-bcb838ba1e5414bb6162fdb0b30f3adc8ccef932.tar.gz |
ctdb-recovery: Move recovery lock functions to recovery daemon code
ctdb_recovery_have_lock(), ctdb_recovery_lock(),
ctdb_recovery_unlock() are only used by recovery daemon, so move them
there.
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb/server/ctdb_recover.c')
-rw-r--r-- | ctdb/server/ctdb_recover.c | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/ctdb/server/ctdb_recover.c b/ctdb/server/ctdb_recover.c index fe7e6e9cb35..e3dbb7c1ff2 100644 --- a/ctdb/server/ctdb_recover.c +++ b/ctdb/server/ctdb_recover.c @@ -927,78 +927,6 @@ int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb, } -bool ctdb_recovery_have_lock(struct ctdb_context *ctdb) -{ - return (ctdb->recovery_lock_handle != NULL); -} - -struct hold_reclock_state { - bool done; - char status; -}; - -static void hold_reclock_handler(struct ctdb_context *ctdb, - char status, - double latency, - struct ctdb_cluster_mutex_handle *h, - void *private_data) -{ - struct hold_reclock_state *s = - (struct hold_reclock_state *) private_data; - - switch (status) { - case '0': - ctdb->recovery_lock_handle = h; - break; - - case '1': - DEBUG(DEBUG_ERR, - ("Unable to take recovery lock - contention\n")); - talloc_free(h); - break; - - default: - DEBUG(DEBUG_ERR, ("ERROR: when taking recovery lock\n")); - talloc_free(h); - } - - s->done = true; - s->status = status; -} - -bool ctdb_recovery_lock(struct ctdb_context *ctdb) -{ - struct ctdb_cluster_mutex_handle *h; - struct hold_reclock_state s = { - .done = false, - .status = '0', - }; - - h = ctdb_cluster_mutex(ctdb, ctdb->recovery_lock_file, 0); - if (h == NULL) { - return -1; - } - - ctdb_cluster_mutex_set_handler(h, hold_reclock_handler, &s); - - while (!s.done) { - tevent_loop_once(ctdb->ev); - } - - /* Ensure no attempts to access to s after function return */ - ctdb_cluster_mutex_set_handler(h, hold_reclock_handler, NULL); - - return (s.status == '0'); -} - -void ctdb_recovery_unlock(struct ctdb_context *ctdb) -{ - if (ctdb->recovery_lock_handle != NULL) { - DEBUG(DEBUG_NOTICE, ("Releasing recovery lock\n")); - TALLOC_FREE(ctdb->recovery_lock_handle); - } -} - /* delete a record as part of the vacuum process only delete if we are not lmaster or dmaster, and our rsn is <= the provided rsn |