ctdb-server: Only talloc_set_destructor when required
authorSwen Schillig <swen@vnet.ibm.com>
Tue, 20 Feb 2018 16:08:59 +0000 (17:08 +0100)
committerJeremy Allison <jra@samba.org>
Fri, 30 Mar 2018 22:07:18 +0000 (00:07 +0200)
The destructor is only needed once the state got added to the DLIST.
Therefore, move the setting of the destructor to after the addition
of state to the DLIST.

Signed-off-by: Swen Schillig <swen@vnet.ibm.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Jeremy Allison <jra@samba.org>
ctdb/server/ctdb_call.c

index 836d615d3c2d6c5bcf8b1ddc6c8374778b7b2d60..ee16a075a692798ba8cb9705a0ed9eef04470795 100644 (file)
@@ -1478,8 +1478,6 @@ struct ctdb_call_state *ctdb_daemon_call_send_remote(struct ctdb_db_context *ctd
 
        state->reqid = reqid_new(ctdb->idr, state);
        state->ctdb_db = ctdb_db;
-       talloc_set_destructor(state, ctdb_call_destructor);
-
        state->state  = CTDB_CALL_WAIT;
        state->generation = ctdb_db->generation;
 
@@ -1516,6 +1514,7 @@ struct ctdb_call_state *ctdb_daemon_call_send_remote(struct ctdb_db_context *ctd
 
        DLIST_ADD(ctdb_db->pending_calls, state);
 
+       talloc_set_destructor(state, ctdb_call_destructor);
        ctdb_queue_packet(ctdb, &state->c->hdr);
 
        return state;