diff options
-rw-r--r-- | ctdb/include/ctdb_private.h | 1 | ||||
-rw-r--r-- | ctdb/server/ctdb_recover.c | 9 | ||||
-rw-r--r-- | ctdb/server/ctdb_recoverd.c | 24 |
3 files changed, 15 insertions, 19 deletions
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index 03130d6602..19fab572a3 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -1261,6 +1261,7 @@ void set_close_on_exec(int fd); bool ctdb_recovery_have_lock(struct ctdb_context *ctdb); bool ctdb_recovery_lock(struct ctdb_context *ctdb, bool keep); +void ctdb_recovery_unlock(struct ctdb_context *ctdb); int ctdb_set_recovery_lock_file(struct ctdb_context *ctdb, const char *file); diff --git a/ctdb/server/ctdb_recover.c b/ctdb/server/ctdb_recover.c index 1f1e50aa29..a4d84fd1a7 100644 --- a/ctdb/server/ctdb_recover.c +++ b/ctdb/server/ctdb_recover.c @@ -784,6 +784,15 @@ bool ctdb_recovery_lock(struct ctdb_context *ctdb, bool keep) return true; } +void ctdb_recovery_unlock(struct ctdb_context *ctdb) +{ + if (ctdb->recovery_lock_fd != -1) { + DEBUG(DEBUG_NOTICE, ("Releasing recovery lock\n")); + close(ctdb->recovery_lock_fd); + ctdb->recovery_lock_fd = -1; + } +} + /* 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 diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c index 3d7c43240a..ba42663a57 100644 --- a/ctdb/server/ctdb_recoverd.c +++ b/ctdb/server/ctdb_recoverd.c @@ -2688,9 +2688,7 @@ static void election_handler(struct ctdb_context *ctdb, uint64_t srvid, /* Release the recovery lock file */ if (em->pnn != ctdb->pnn && ctdb_recovery_have_lock(ctdb)) { - DEBUG(DEBUG_NOTICE, ("Release the recovery lock\n")); - close(ctdb->recovery_lock_fd); - ctdb->recovery_lock_fd = -1; + ctdb_recovery_unlock(ctdb); unban_all_nodes(ctdb); } } @@ -3478,10 +3476,7 @@ static int update_recovery_lock_file(struct ctdb_context *ctdb) DEBUG(DEBUG_ERR,("Reclock file disabled\n")); talloc_free(ctdb->recovery_lock_file); ctdb->recovery_lock_file = NULL; - if (ctdb->recovery_lock_fd != -1) { - close(ctdb->recovery_lock_fd); - ctdb->recovery_lock_fd = -1; - } + ctdb_recovery_unlock(ctdb); } talloc_free(tmp_ctx); return 0; @@ -3489,10 +3484,7 @@ static int update_recovery_lock_file(struct ctdb_context *ctdb) if (ctdb->recovery_lock_file == NULL) { ctdb->recovery_lock_file = talloc_strdup(ctdb, reclockfile); - if (ctdb->recovery_lock_fd != -1) { - close(ctdb->recovery_lock_fd); - ctdb->recovery_lock_fd = -1; - } + ctdb_recovery_unlock(ctdb); talloc_free(tmp_ctx); return 0; } @@ -3505,10 +3497,7 @@ static int update_recovery_lock_file(struct ctdb_context *ctdb) talloc_free(ctdb->recovery_lock_file); ctdb->recovery_lock_file = talloc_strdup(ctdb, reclockfile); - if (ctdb->recovery_lock_fd != -1) { - close(ctdb->recovery_lock_fd); - ctdb->recovery_lock_fd = -1; - } + ctdb_recovery_unlock(ctdb); talloc_free(tmp_ctx); return 0; @@ -3575,10 +3564,7 @@ static void main_loop(struct ctdb_context *ctdb, struct ctdb_recoverd *rec, we close the file */ if (ctdb->recovery_lock_file == NULL) { - if (ctdb->recovery_lock_fd != -1) { - close(ctdb->recovery_lock_fd); - ctdb->recovery_lock_fd = -1; - } + ctdb_recovery_unlock(ctdb); } pnn = ctdb_get_pnn(ctdb); |