From 9745524234ab57aa8a895fb90a5dad35d9064ce4 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Mon, 3 Sep 2018 11:43:44 +1000 Subject: ctdb-recoverd: Use talloc() to allocate recovery lock handle At the moment this is still local and is freed after the mutex is successfully taken. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13617 Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs (cherry picked from commit a53b264aee7d620ee8ecf9114b0014c5bb678484) --- ctdb/server/ctdb_recoverd.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'ctdb') diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c index 85583241e3a..341e4c82fb9 100644 --- a/ctdb/server/ctdb_recoverd.c +++ b/ctdb/server/ctdb_recoverd.c @@ -930,31 +930,43 @@ static bool ctdb_recovery_lock(struct ctdb_recoverd *rec) { struct ctdb_context *ctdb = rec->ctdb; struct ctdb_cluster_mutex_handle *h; - struct ctdb_recovery_lock_handle s = { - .done = false, - .locked = false, - .latency = 0, + struct ctdb_recovery_lock_handle *s; + + s = talloc_zero(rec, struct ctdb_recovery_lock_handle); + if (s == NULL) { + DBG_ERR("Memory allocation error\n"); + return false; }; - h = ctdb_cluster_mutex(rec, ctdb, ctdb->recovery_lock, 0, - take_reclock_handler, &s, - lost_reclock_handler, rec); + h = ctdb_cluster_mutex(rec, + ctdb, + ctdb->recovery_lock, + 0, + take_reclock_handler, + s, + lost_reclock_handler, + rec); if (h == NULL) { + talloc_free(s); return false; } - while (!s.done) { + while (! s->done) { tevent_loop_once(ctdb->ev); } - if (! s.locked) { + if (! s->locked) { + talloc_free(s); talloc_free(h); return false; } rec->recovery_lock_handle = h; - ctdb_ctrl_report_recd_lock_latency(ctdb, CONTROL_TIMEOUT(), - s.latency); + ctdb_ctrl_report_recd_lock_latency(ctdb, + CONTROL_TIMEOUT(), + s->latency); + + talloc_free(s); return true; } -- cgit v1.2.1