From: Martin Schwenke Date: Mon, 3 Sep 2018 01:43:44 +0000 (+1000) Subject: ctdb-recoverd: Use talloc() to allocate recovery lock handle X-Git-Tag: samba-4.8.6~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9745524234ab57aa8a895fb90a5dad35d9064ce4;p=thirdparty%2Fsamba.git 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) --- 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; }