s4: torture: Remove the last talloc_autofree_context() from source4/torture/*.c
authorJeremy Allison <jra@samba.org>
Mon, 24 Apr 2017 23:40:37 +0000 (16:40 -0700)
committerJeremy Allison <jra@samba.org>
Fri, 5 May 2017 17:47:50 +0000 (19:47 +0200)
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 <jra@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri May  5 19:47:50 CEST 2017 on sn-devel-144

source4/torture/rpc/spoolss_notify.c

index 928b61935aa34562b841a2a69c690a423f512759..bcae5f8b17bd0025ba34ed0df2c438e97108da25 100644 (file)
@@ -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;
 }