1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

ctdb-recoverd: New function ctdb_recovery_unlock()

Unlock the recovery lock file.  This way knowledge of the file
descriptor isn't sprinkled throughout the code.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
Martin Schwenke 2014-12-09 14:07:20 +11:00 committed by Amitay Isaacs
parent 72701be663
commit db32a2bce5
3 changed files with 15 additions and 19 deletions

View File

@ -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);

View File

@ -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

View File

@ -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);