From: Jeremy Allison Date: Mon, 24 Apr 2017 23:40:37 +0000 (-0700) Subject: s4: torture: Remove the last talloc_autofree_context() from source4/torture/*.c X-Git-Tag: ldb-1.1.30~306 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=825d00df19f32845a66b080354824fada946d620;p=thirdparty%2Fsamba.git s4: torture: Remove the last talloc_autofree_context() from source4/torture/*.c Allocate the saved packets off the NULL context instead, and use a new function free_received_packets() to clear out the received_packets list. Signed-off-by: Jeremy Allison Reviewed-by: Ralph Böhme Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Fri May 5 19:47:50 CEST 2017 on sn-devel-144 --- diff --git a/source4/torture/rpc/spoolss_notify.c b/source4/torture/rpc/spoolss_notify.c index 928b61935aa..bcae5f8b17b 100644 --- a/source4/torture/rpc/spoolss_notify.c +++ b/source4/torture/rpc/spoolss_notify.c @@ -72,7 +72,7 @@ static NTSTATUS spoolss__op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_ return NT_STATUS_OK; } -/* Note that received_packets are allocated in talloc_autofree_context(), +/* Note that received_packets are allocated on the NULL context * because no other context appears to stay around long enough. */ static struct received_packet { uint16_t opnum; @@ -80,6 +80,20 @@ static struct received_packet { struct received_packet *prev, *next; } *received_packets = NULL; +static void free_received_packets(void) +{ + struct received_packet *rp; + struct received_packet *rp_next; + + for (rp = received_packets; rp; rp = rp_next) { + rp_next = rp->next; + DLIST_REMOVE(received_packets, rp); + talloc_unlink(rp, rp->r); + talloc_free(rp); + } + received_packets = NULL; +} + static WERROR _spoolss_ReplyOpenPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct spoolss_ReplyOpenPrinter *r) @@ -136,7 +150,7 @@ static NTSTATUS spoolss__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_ uint16_t opnum = dce_call->pkt.u.request.opnum; struct received_packet *rp; - rp = talloc_zero(talloc_autofree_context(), struct received_packet); + rp = talloc_zero(NULL, struct received_packet); rp->opnum = opnum; rp->r = talloc_reference(rp, r); @@ -502,7 +516,7 @@ static bool test_RFFPCNEx(struct torture_context *tctx, const char *printername = NULL; struct spoolss_NotifyInfo *info = NULL; - received_packets = NULL; + free_received_packets(); /* Start DCE/RPC server */ torture_assert(tctx, test_start_dcerpc_server(tctx, tctx->ev, &dce_ctx, &address), ""); @@ -541,6 +555,7 @@ static bool test_RFFPCNEx(struct torture_context *tctx, #endif /* Shut down DCE/RPC server */ talloc_free(dce_ctx); + free_received_packets(); return true; }