]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
subrequest: Resume the parent if the child is cancelled
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 18 Mar 2023 04:37:20 +0000 (00:37 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 27 Mar 2023 22:59:41 +0000 (16:59 -0600)
src/lib/unlang/subrequest_child.c

index 2b0ca4524c7c4d6b7453b702f1abcb732c881fd9..2186c7d7ad078caf8e3ec801ede804b2c1066614 100644 (file)
@@ -127,35 +127,44 @@ static void unlang_subrequest_child_signal(request_t *request, fr_state_signal_t
 {
        unlang_frame_state_subrequest_t *state;
 
+       if (!request->parent) return;
+
+       state = talloc_get_type_abort(frame_current(request->parent)->state, unlang_frame_state_subrequest_t);
+
        /*
-        *      Ignore signals which aren't detach,
+        *      Ignore signals which aren't detach, and ar
         *      and ignore the signal if we have no parent.
         */
-       if ((action != FR_SIGNAL_DETACH) || !request->parent) return;
+       switch (action) {
+       case FR_SIGNAL_DETACH:
+               /*
+                *      Place child's state back inside the parent
+                */
+               if (state->session.enable) fr_state_store_in_parent(request,
+                                                                   state->session.unique_ptr,
+                                                                   state->session.unique_int);
+
+               if (!fr_cond_assert(unlang_subrequest_lifetime_set(request) == 0)) {
+                       REDEBUG("Child could not be detached");
+                       return;
+               }
+               FALL_THROUGH;
 
-       state = talloc_get_type_abort(frame_current(request->parent), unlang_frame_state_subrequest_t);
+       case FR_SIGNAL_CANCEL:
+               /*
+                *      Indicate to the parent there's no longer a child
+                */
+               state->child = NULL;
 
-       /*
-        *      Place child's state back inside the parent
-        */
-       if (state->session.enable) fr_state_store_in_parent(request,
-                                                           state->session.unique_ptr,
-                                                           state->session.unique_int);
+               /*
+                *      Tell the parent to resume
+                */
+               unlang_interpret_mark_runnable(request->parent);
+               break;
 
-       if (!fr_cond_assert(unlang_subrequest_lifetime_set(request) == 0)) {
-               REDEBUG("Child could not be detached");
+       default:
                return;
        }
-
-       /*
-        *      Indicate to the parent there's no longer a child
-        */
-       state->child = NULL;
-
-       /*
-        *      Tell the parent to resume
-        */
-       unlang_interpret_mark_runnable(request->parent);
 }
 
 /** When the child is done, tell the parent that we've exited.