[PATCH] ctdb-server: Minor code cleanup
Swen Schillig
swen at vnet.ibm.com
Fri Mar 9 08:14:04 UTC 2018
Please review and push if OK.
Thanks in advance.
Cheers Swen
-------------- next part --------------
From e3b40e17e30154fb2e01f316d355d3a0244c24ea Mon Sep 17 00:00:00 2001
From: Swen Schillig <swen at vnet.ibm.com>
Date: Thu, 8 Feb 2018 11:57:23 +0100
Subject: [PATCH] ctdb-server: Minor code cleanup
Cleanup ctdb_start_revoke_ro_record to improve readability.
Signed-off-by: Swen Schillig <swen at vnet.ibm.com>
---
ctdb/server/ctdb_call.c | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/ctdb/server/ctdb_call.c b/ctdb/server/ctdb_call.c
index a3b45dfe2c8..6fa3d14c595 100644
--- a/ctdb/server/ctdb_call.c
+++ b/ctdb/server/ctdb_call.c
@@ -1811,14 +1811,19 @@ static int ctdb_revoke_all_delegations(struct ctdb_context *ctdb, struct ctdb_db
}
-int ctdb_start_revoke_ro_record(struct ctdb_context *ctdb, struct ctdb_db_context *ctdb_db, TDB_DATA key, struct ctdb_ltdb_header *header, TDB_DATA data)
+int ctdb_start_revoke_ro_record(struct ctdb_context *ctdb,
+ struct ctdb_db_context *ctdb_db, TDB_DATA key,
+ struct ctdb_ltdb_header *header, TDB_DATA data)
{
TDB_DATA tdata;
struct revokechild_handle *rev_hdl;
pid_t parent = getpid();
int ret;
- header->flags &= ~(CTDB_REC_RO_REVOKING_READONLY|CTDB_REC_RO_HAVE_DELEGATIONS|CTDB_REC_RO_HAVE_READONLY);
+ header->flags &= ~(CTDB_REC_RO_REVOKING_READONLY |
+ CTDB_REC_RO_HAVE_DELEGATIONS |
+ CTDB_REC_RO_HAVE_READONLY);
+
header->flags |= CTDB_REC_FLAG_MIGRATED_WITH_DATA;
header->rsn -= 1;
@@ -1826,7 +1831,7 @@ int ctdb_start_revoke_ro_record(struct ctdb_context *ctdb, struct ctdb_db_contex
data.dsize + key.dsize);
if (rev_hdl == NULL) {
- DEBUG(DEBUG_ERR,("Failed to allocate revokechild_handle\n"));
+ D_ERR("Failed to allocate revokechild_handle\n");
return -1;
}
@@ -1850,14 +1855,14 @@ int ctdb_start_revoke_ro_record(struct ctdb_context *ctdb, struct ctdb_db_contex
rev_hdl->key.dsize = key.dsize;
rev_hdl->key.dptr = talloc_memdup(rev_hdl, key.dptr, key.dsize);
if (rev_hdl->key.dptr == NULL) {
- DEBUG(DEBUG_ERR,("Failed to allocate key for revokechild_handle\n"));
+ D_ERR("Failed to allocate key for revokechild_handle\n");
talloc_free(rev_hdl);
return -1;
}
ret = pipe(rev_hdl->fd);
if (ret != 0) {
- DEBUG(DEBUG_ERR,("Failed to allocate key for revokechild_handle\n"));
+ D_ERR("Failed to allocate key for revokechild_handle\n");
talloc_free(rev_hdl);
return -1;
}
@@ -1865,7 +1870,7 @@ int ctdb_start_revoke_ro_record(struct ctdb_context *ctdb, struct ctdb_db_contex
rev_hdl->child = ctdb_fork(ctdb);
if (rev_hdl->child == (pid_t)-1) {
- DEBUG(DEBUG_ERR,("Failed to fork child for revokechild\n"));
+ D_ERR("Failed to fork child for revokechild\n");
talloc_free(rev_hdl);
return -1;
}
@@ -1876,12 +1881,14 @@ int ctdb_start_revoke_ro_record(struct ctdb_context *ctdb, struct ctdb_db_contex
prctl_set_comment("ctdb_revokechild");
if (switch_from_server_to_client(ctdb) != 0) {
- DEBUG(DEBUG_ERR,("Failed to switch from server to client for revokechild process\n"));
+ D_ERR("Failed to switch from server to client "
+ "for revokechild process\n");
c = 1;
goto child_finished;
}
- c = ctdb_revoke_all_delegations(ctdb, ctdb_db, tdata, key, header, data);
+ c = ctdb_revoke_all_delegations(ctdb, ctdb_db, tdata, key,
+ header, data);
child_finished:
sys_write(rev_hdl->fd[1], &c, 1);
@@ -1896,10 +1903,11 @@ child_finished:
/* This is an active revokechild child process */
DLIST_ADD_END(ctdb_db->revokechild_active, rev_hdl);
- rev_hdl->fde = tevent_add_fd(ctdb->ev, rev_hdl, rev_hdl->fd[0], TEVENT_FD_READ,
- revokechild_handler, (void *)rev_hdl);
+ rev_hdl->fde = tevent_add_fd(ctdb->ev, rev_hdl, rev_hdl->fd[0],
+ TEVENT_FD_READ, revokechild_handler,
+ (void *)rev_hdl);
if (rev_hdl->fde == NULL) {
- DEBUG(DEBUG_ERR,("Failed to set up fd event for revokechild process\n"));
+ D_ERR("Failed to set up fd event for revokechild process\n");
talloc_free(rev_hdl);
}
tevent_fd_set_auto_close(rev_hdl->fde);
--
2.14.3
More information about the samba-technical
mailing list