ctdb-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)
committerMichael Adam <obnox@samba.org>
Tue, 12 Jan 2016 18:16:17 +0000 (19:16 +0100)
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
ctdb/server/ctdb_recover.c

index 7b34d7e2913a063ea746159be52308d83ee95ec9..127ff6bdfbf0e2cee721436f00b20f84489a84c0 100644 (file)
@@ -592,13 +592,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);
@@ -610,6 +603,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