diff options
author | Martin Schwenke <martin@meltin.net> | 2020-04-02 14:18:33 +1100 |
---|---|---|
committer | Amitay Isaacs <amitay@samba.org> | 2020-04-07 01:26:41 +0000 |
commit | 7ad7c0b9324c30b32e972df4cbff229e380d71f1 (patch) | |
tree | 2beb17cb5646f066544072873d492e46501b2f19 /ctdb | |
parent | c4be195da2845be4f64e47883e3c911dedd90e48 (diff) | |
download | samba-7ad7c0b9324c30b32e972df4cbff229e380d71f1.tar.gz |
ctdb-vacuum: Use vacuum_handle local variables
No behaviour change. This just makes future changes clearer by
avoiding reformatting (or introducing local variables).
Clean up error handling while touching a relevant line.
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb')
-rw-r--r-- | ctdb/server/ctdb_vacuum.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/ctdb/server/ctdb_vacuum.c b/ctdb/server/ctdb_vacuum.c index 5351a3c5175..b159b7d6a34 100644 --- a/ctdb/server/ctdb_vacuum.c +++ b/ctdb/server/ctdb_vacuum.c @@ -1314,7 +1314,8 @@ static uint32_t get_vacuum_interval(struct ctdb_db_context *ctdb_db) static int vacuum_child_destructor(struct ctdb_vacuum_child_context *child_ctx) { double l = timeval_elapsed(&child_ctx->start_time); - struct ctdb_db_context *ctdb_db = child_ctx->vacuum_handle->ctdb_db; + struct ctdb_vacuum_handle *vacuum_handle = child_ctx->vacuum_handle; + struct ctdb_db_context *ctdb_db = vacuum_handle->ctdb_db; struct ctdb_context *ctdb = ctdb_db->ctdb; CTDB_UPDATE_DB_LATENCY(ctdb_db, "vacuum", vacuum.latency, l); @@ -1324,7 +1325,7 @@ static int vacuum_child_destructor(struct ctdb_vacuum_child_context *child_ctx) ctdb_kill(ctdb, child_ctx->child_pid, SIGKILL); } else { /* Bump the number of successful fast-path runs. */ - child_ctx->vacuum_handle->fast_path_count++; + vacuum_handle->fast_path_count++; } ctdb->vacuumer = NULL; @@ -1332,10 +1333,10 @@ static int vacuum_child_destructor(struct ctdb_vacuum_child_context *child_ctx) if (child_ctx->scheduled) { tevent_add_timer( ctdb->ev, - child_ctx->vacuum_handle, + vacuum_handle, timeval_current_ofs(get_vacuum_interval(ctdb_db), 0), ctdb_vacuum_event, - child_ctx->vacuum_handle); + vacuum_handle); } return 0; @@ -1660,6 +1661,8 @@ void ctdb_stop_vacuuming(struct ctdb_context *ctdb) */ int ctdb_vacuum_init(struct ctdb_db_context *ctdb_db) { + struct ctdb_vacuum_handle *vacuum_handle; + if (! ctdb_db_volatile(ctdb_db)) { DEBUG(DEBUG_ERR, ("Vacuuming is disabled for non-volatile database %s\n", @@ -1667,15 +1670,22 @@ int ctdb_vacuum_init(struct ctdb_db_context *ctdb_db) return 0; } - ctdb_db->vacuum_handle = talloc(ctdb_db, struct ctdb_vacuum_handle); - CTDB_NO_MEMORY(ctdb_db->ctdb, ctdb_db->vacuum_handle); + vacuum_handle = talloc(ctdb_db, struct ctdb_vacuum_handle); + if (vacuum_handle == NULL) { + DBG_ERR("Memory allocation error\n"); + return -1; + } + + vacuum_handle->ctdb_db = ctdb_db; + vacuum_handle->fast_path_count = 0; - ctdb_db->vacuum_handle->ctdb_db = ctdb_db; - ctdb_db->vacuum_handle->fast_path_count = 0; + ctdb_db->vacuum_handle = vacuum_handle; - tevent_add_timer(ctdb_db->ctdb->ev, ctdb_db->vacuum_handle, + tevent_add_timer(ctdb_db->ctdb->ev, + vacuum_handle, timeval_current_ofs(get_vacuum_interval(ctdb_db), 0), - ctdb_vacuum_event, ctdb_db->vacuum_handle); + ctdb_vacuum_event, + vacuum_handle); return 0; } |