]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Unpick some cross dependencies with detach functions
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 5 Apr 2021 21:37:12 +0000 (22:37 +0100)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 5 Apr 2021 21:37:12 +0000 (22:37 +0100)
src/lib/server/request.c
src/lib/unlang/interpret.c
src/lib/unlang/parallel.c
src/lib/unlang/subrequest.h
src/lib/unlang/subrequest_child.c

index a0d9aff57449d011c6f0d237b89bf5e469049125..28ac9140b4e32f17c5407d5c82b28fa9a0ef93b5 100644 (file)
@@ -555,14 +555,15 @@ int request_detach(request_t *child)
 {
        request_t               *request = child->parent;
 
-       if (!request) return 0; /* Already detached */
-
        /*
-        *      Let any signal handler that cares
-        *      know that the child is about to
-        *      be detached.
+        *      Already detached or not detachable
         */
-       unlang_interpret_signal(child, FR_SIGNAL_DETACH);
+       if (request_is_detached(child)) return 0;
+
+       if (!request_is_detachable(child)) {
+               RERROR("Request is not detachable");
+               return -1;
+       }
 
        /*
         *      Unlink the child from the parent.
@@ -571,6 +572,11 @@ int request_detach(request_t *child)
 
        child->parent = NULL;
 
+       /*
+        *      Request is now detached
+        */
+       child->type = REQUEST_TYPE_DETACHED;
+
        return 0;
 }
 
index afc1e07e93deefe21cbc7a74bb2a056631302714..3c38b060b217b385ce56ac1d4b87ffef9b7a547b 100644 (file)
@@ -944,6 +944,7 @@ void unlang_interpret_signal(request_t *request, fr_state_signal_t action)
 
        case FR_SIGNAL_DETACH:
                unlang_interpret_request_detach(request);       /* Tell our caller that the request is being detached */
+               request_detach(request);                        /* Finish detaching the request */
                break;
 
        default:
index a105deea3548efb92f7da9e48fb00a9721c43a90..216c2df741d837224e09dd0488ce07918ceb19de 100644 (file)
@@ -346,7 +346,7 @@ static unlang_action_t unlang_parallel_process(rlm_rcode_t *p_result, request_t
                         *      Detach the child, and insert
                         *      it into the backlog.
                         */
-                       if (unlang_subrequest_child_detach(child) < 0) {
+                       if ((unlang_subrequest_lifetime_set(child) < 0) || (request_detach(request) < 0)) {
                                talloc_free(child);
 
                                RETURN_MODULE_FAIL;
index d7251e3ecbfe82337cc68c054ffde4832933293f..8c386c4174701dfc65eac59552007c6176b1c895 100644 (file)
@@ -37,7 +37,7 @@ typedef struct {
        int             unique_int;                     //!< Session unique int identifier.
 } unlang_subrequest_session_t;
 
-int            unlang_subrequest_child_detach(request_t *request);
+int            unlang_subrequest_lifetime_set(request_t *request);
 
 int            unlang_subrequest_child_push(rlm_rcode_t *out, request_t *child,
                                             unlang_subrequest_session_t const *session,
index 60b795936d4f570757f7d855338cbe53986d419c..0dcc707f781ffc76a1bec55c280ae6f89cc57d06 100644 (file)
@@ -80,15 +80,10 @@ static void unlang_detached_max_request_time(UNUSED fr_event_list_t *el, UNUSED
  *  Detach it from the parent, set up it's lifetime, and mark it as
  *  runnable.
  */
-int unlang_subrequest_child_detach(request_t *request)
+int unlang_subrequest_lifetime_set(request_t *request)
 {
        fr_pair_t               *vp;
 
-       if (request_detach(request) < 0) {
-               ERROR("Failed detaching child");
-               return -1;
-       }
-
        /*
         *      Set Request Lifetime
         */
@@ -149,7 +144,7 @@ static void unlang_subrequest_child_signal(request_t *request, fr_state_signal_t
                                                            state->session.unique_ptr,
                                                            state->session.unique_int);
 
-       if (!fr_cond_assert(unlang_subrequest_child_detach(request) == 0)) {
+       if (!fr_cond_assert(unlang_subrequest_lifetime_set(request) == 0)) {
                REDEBUG("Child could not be detached");
                return;
        }
@@ -344,7 +339,7 @@ int unlang_subrequest_child_push_and_detach(request_t *child)
         */
        interpret_child_init(child);
 
-       if (unlang_subrequest_child_detach(child) < 0) return -1;
+       if ((unlang_subrequest_lifetime_set(child) < 0) || (request_detach(child) < 0)) return -1;
 
        return 0;
 }