]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
clean up internal requests if they have no parent
authorAlan T. DeKok <aland@freeradius.org>
Wed, 18 May 2022 00:17:51 +0000 (20:17 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 18 May 2022 00:20:54 +0000 (20:20 -0400)
Specifically for trigger_exec(), which can be called with
a real interpreter, but no parent for the "request" which is
running the trigger.

src/lib/io/worker.c
src/lib/server/trigger.c
src/lib/unlang/interpret_synchronous.c

index a5de9fc2fcf03930b6fd486eb62be4c6e6dda45a..781c2394ac5b673c6d397554fbb0016655fed2a8 100644 (file)
@@ -996,7 +996,8 @@ static void _worker_request_done_external(request_t *request, UNUSED rlm_rcode_t
 
 /** Internal request (i.e. one generated by the interpreter) is now complete
  *
- * Whatever generated the request is now responsible for freeing it.
+ * Whatever generated the request is now responsible for freeing it,
+ * unless there's no talloc parent.  In which case we have to free it.
  */
 static void _worker_request_done_internal(request_t *request, UNUSED rlm_rcode_t rcode, void *uctx)
 {
@@ -1006,6 +1007,8 @@ static void _worker_request_done_internal(request_t *request, UNUSED rlm_rcode_t
 
        fr_assert(!fr_heap_entry_inserted(request->runnable_id));
        fr_assert(!fr_minmax_heap_entry_inserted(request->time_order_id));
+
+       if (!talloc_parent(request)) talloc_free(request);
 }
 
 /** Detached request (i.e. one generated by the interpreter with no parent) is now complete
index c8f5fcee1b182328afdc3b63faff43b506bab0ad..8a999f672353584540f48d28dfb2e6e8c3495982 100644 (file)
@@ -457,11 +457,10 @@ int trigger_exec(unlang_interpret_t *intp,
                 *      shutting down.
                 */
                unlang_interpret_synchronous(NULL, request);
-               talloc_free(request);
        }
 
        /*
-        *      Otherwise the worker cleans up the request request.
+        *      Otherwise the worker cleans up the request.
         */
        return 0;
 }
index 601270803921e058edca2af27750dac926e2c89c..89218a7b524b2f884207ec0421723e210acd8e90 100644 (file)
@@ -71,12 +71,14 @@ static void _request_done_external(request_t *request, UNUSED rlm_rcode_t rcode,
 
 /** Internal request (i.e. one generated by the interpreter) is now complete
  *
+ * Whatever generated the request is now responsible for freeing it,
+ * unless there's no talloc parent.  In which case we have to free it.
  */
 static void _request_done_internal(request_t *request, UNUSED rlm_rcode_t rcode, UNUSED void *uctx)
 {
        RDEBUG3("Done synchronous internal request");
 
-       /* Request will be cleaned up by whatever created it */
+       if (!talloc_parent(request)) talloc_free(request);
 }
 
 static void _request_done_detached(request_t *request, UNUSED rlm_rcode_t rcode, UNUSED void *uctx)