From: Rusty Russell Date: Fri, 21 Jan 2011 03:55:12 +0000 (+1030) Subject: lca2011: oserver_restore to restore talloc hierarchy. X-Git-Url: http://git.ozlabs.org/?a=commitdiff_plain;h=b6c158bea04f0b8ec13b70c5a3f68aef74c4e356;p=ccan-lca-2011.git lca2011: oserver_restore to restore talloc hierarchy. --- diff --git a/ccan/oserver/oserver.c b/ccan/oserver/oserver.c index 50b49bd..405a576 100644 --- a/ccan/oserver/oserver.c +++ b/ccan/oserver/oserver.c @@ -358,18 +358,25 @@ struct oserver *oserver_restore(struct tevent_context *ev, const char *dumpfile) return NULL; } - /* Restore ignored fields in clients (fde and oserver). */ + /* Restore ignored fields in clients, and talloc hierarchy. */ for (i = 0; i < ARRAY_SIZE(oserver->clients); i++) { struct client *client = oserver->clients[i]; if (!client) continue; + /* These two were marked CDUMP_IGNORE. */ client->oserver = oserver; client->fde = tevent_add_fd(ev, client, client->fd, state_flag_map[client->state], service_client, client); tevent_fd_set_auto_close(client->fde); + /* cdump knows nothing of talloc. */ + talloc_steal(oserver, client); + talloc_steal(client, client->question); + talloc_steal(client, client->answer); + talloc_set_destructor(client, cleanup_client); } + talloc_set_destructor(oserver, destroy_oserver); if (!complete_server(ev, oserver, dumpfile)) { talloc_free(oserver); return NULL;