From: Arran Cudbard-Bell Date: Thu, 30 Apr 2020 01:18:22 +0000 (-0500) Subject: Add destructor so we can set a breakpoint for state ctx freeing X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d15bcd86707bb971ada97993a203b2efe5a79e48;p=thirdparty%2Ffreeradius-server.git Add destructor so we can set a breakpoint for state ctx freeing --- diff --git a/src/lib/server/request.c b/src/lib/server/request.c index b603d6225a8..4fb035a4fa1 100644 --- a/src/lib/server/request.c +++ b/src/lib/server/request.c @@ -34,6 +34,15 @@ RCSID("$Id$") */ static _Thread_local fr_dlist_head_t *request_free_list; /* macro */ +#ifndef NDEBUG +static int _state_ctx_free(TALLOC_CTX *state) +{ + DEBUG4("state-ctx %p freed", state); + + return 0; +} +#endif + /** Setup logging and other fields for a request * * @param[in] file the request was allocated in. @@ -62,7 +71,12 @@ static void request_init(char const *file, int line, REQUEST *request) /* * Initialise the state_ctx */ - if (!request->state_ctx) request->state_ctx = talloc_init_const("session-state"); + if (!request->state_ctx) { + request->state_ctx = talloc_init_const("session-state"); +#ifndef NDEBUG + talloc_set_destructor(request->state_ctx, _state_ctx_free); +#endif + } /* * These may be changed later by request_pre_handler