ctdb-tools: Move special case of 0 connections into computation
[metze/samba/wip.git] / ctdb / tools / ctdb_killtcp.c
index 1917652ee66165a96407c4c9768fce4ad99b7084..a004f72445185b07160e002dc23afae5e194d5d3 100644 (file)
@@ -76,6 +76,12 @@ static struct tevent_req *reset_connections_send(
 
        state->ev = ev;
 
+       if (conn_list->num == 0) {
+               /* No connections, done! */
+               tevent_req_done(req);
+               return tevent_req_post(req, ev);
+       }
+
        ret = db_hash_init(state, "connections", 2048, DB_HASH_SIMPLE,
                           &state->connections);
        if (ret != 0) {
@@ -378,12 +384,6 @@ int main(int argc, char **argv)
                goto fail;
        }
 
-       if (conn_list->num == 0) {
-               /* No connections, done! */
-               talloc_free(mem_ctx);
-               return 0;
-       }
-
        req = reset_connections_send(mem_ctx, ev, argv[1], conn_list);
        if (req == NULL) {
                goto fail;