daemon: Don't leak memory if not using recovery lock
authorMartin Schwenke <martin@meltin.net>
Mon, 11 Jan 2016 02:41:30 +0000 (13:41 +1100)
committerMartin Schwenke <martin@meltin.net>
Wed, 24 Feb 2016 10:44:28 +0000 (21:44 +1100)
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
(Imported from commit 24160ee6a4a0727840d73955b99aef690450f345)

server/ctdb_recover.c

index 122ee088dda32c6638481f5887218dd821aa96cf..cba952c2189fb17929d32da3bb5a4b8a7b488abe 100644 (file)
@@ -629,13 +629,6 @@ int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb,
                }
        }
 
-       state = talloc(ctdb, struct ctdb_set_recmode_state);
-       CTDB_NO_MEMORY(ctdb, state);
-
-       state->start_time = timeval_current();
-       state->fd[0] = -1;
-       state->fd[1] = -1;
-
        /* release any deferred attach calls from clients */
        if (recmode == CTDB_RECOVERY_NORMAL) {
                ctdb_process_deferred_attach(ctdb);
@@ -647,6 +640,13 @@ int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb,
                return 0;
        }
 
+       state = talloc(ctdb, struct ctdb_set_recmode_state);
+       CTDB_NO_MEMORY(ctdb, state);
+
+       state->start_time = timeval_current();
+       state->fd[0] = -1;
+       state->fd[1] = -1;
+
        /* For the rest of what needs to be done, we need to do this in
           a child process since 
           1, the call to ctdb_recovery_lock() can block if the cluster