ctdb-server: Only set destructor if required
authorSwen Schillig <swen@vnet.ibm.com>
Thu, 8 Feb 2018 11:19:09 +0000 (12:19 +0100)
committerJeremy Allison <jra@samba.org>
Sat, 31 Mar 2018 01:45:51 +0000 (03:45 +0200)
Set the detructor in ctdb_start_revoke_ro_record after the revokechild_handle
was added to the list.

Signed-off-by: Swen Schillig <swen@vnet.ibm.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sat Mar 31 03:45:51 CEST 2018 on sn-devel-144

ctdb/server/ctdb_call.c

index beaae42..0305920 100644 (file)
@@ -1863,8 +1863,6 @@ int ctdb_start_revoke_ro_record(struct ctdb_context *ctdb,
        rev_hdl->fd[0]     = -1;
        rev_hdl->fd[1]     = -1;
 
-       talloc_set_destructor(rev_hdl, revokechild_destructor);
-
        rev_hdl->key.dsize = key.dsize;
        rev_hdl->key.dptr  = talloc_memdup(rev_hdl, key.dptr, key.dsize);
        if (rev_hdl->key.dptr == NULL) {
@@ -1914,9 +1912,6 @@ child_finished:
        rev_hdl->fd[1] = -1;
        set_close_on_exec(rev_hdl->fd[0]);
 
-       /* This is an active revokechild child process */
-       DLIST_ADD_END(ctdb_db->revokechild_active, rev_hdl);
-
        rev_hdl->fde = tevent_add_fd(ctdb->ev,
                                     rev_hdl,
                                     rev_hdl->fd[0],
@@ -1930,6 +1925,10 @@ child_finished:
        }
        tevent_fd_set_auto_close(rev_hdl->fde);
 
+       /* This is an active revokechild child process */
+       DLIST_ADD_END(ctdb_db->revokechild_active, rev_hdl);
+       talloc_set_destructor(rev_hdl, revokechild_destructor);
+
        return 0;
 err_out:
        talloc_free(rev_hdl);