diff options
author | Martin Schwenke <martin@meltin.net> | 2018-09-03 11:43:44 +1000 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2018-09-20 09:13:12 +0200 |
commit | 9745524234ab57aa8a895fb90a5dad35d9064ce4 (patch) | |
tree | 57142305fc8dc0132b2539e1add31377e7284423 /ctdb | |
parent | a4c438601a623d2b47023621a9f0e341135192d4 (diff) | |
download | samba-9745524234ab57aa8a895fb90a5dad35d9064ce4.tar.gz |
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 <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit a53b264aee7d620ee8ecf9114b0014c5bb678484)
Diffstat (limited to 'ctdb')
-rw-r--r-- | ctdb/server/ctdb_recoverd.c | 34 |
1 files changed, 23 insertions, 11 deletions
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; } |