]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-recoverd: Use talloc() to allocate recovery lock handle
authorMartin Schwenke <martin@meltin.net>
Mon, 3 Sep 2018 01:43:44 +0000 (11:43 +1000)
committerKarolin Seeger <kseeger@samba.org>
Thu, 20 Sep 2018 07:13:12 +0000 (09:13 +0200)
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)

ctdb/server/ctdb_recoverd.c

index 85583241e3a56072bde3064a5e971ac70c1b6162..341e4c82fb96a21d13e0a732f1633309e9eacb23 100644 (file)
@@ -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;
 }