]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Correct handling of trunk enqueue responses
authorNick Porter <nick@portercomputing.co.uk>
Wed, 18 Oct 2023 20:06:56 +0000 (21:06 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Wed, 18 Oct 2023 20:49:57 +0000 (21:49 +0100)
src/modules/rlm_radius/rlm_radius_udp.c

index 05847d69e5c9f574a12bd01ea6ccf5f0efd704fa..f77ec9bb1d45fd6825d18233f4279adccbf0f167 100644 (file)
@@ -2706,7 +2706,6 @@ static unlang_action_t mod_enqueue(rlm_rcode_t *p_result, void **rctx_out, void
        udp_result_t                    *r;
        udp_request_t                   *u;
        fr_trunk_request_t              *treq;
-       fr_trunk_enqueue_t              q;
 
        fr_assert(request->packet->code > 0);
        fr_assert(request->packet->code < FR_RADIUS_CODE_MAX);
@@ -2751,21 +2750,25 @@ static unlang_action_t mod_enqueue(rlm_rcode_t *p_result, void **rctx_out, void
                pair_delete_request(attr_message_authenticator);
        }
 
-       q = fr_trunk_request_enqueue(&treq, t->trunk, request, u, r);
-       if (q < 0) {
+       switch(fr_trunk_request_enqueue(&treq, t->trunk, request, u, r)) {
+       case FR_TRUNK_ENQUEUE_OK:
+       case FR_TRUNK_ENQUEUE_IN_BACKLOG:
+               break;
+
+       case FR_TRUNK_ENQUEUE_NO_CAPACITY:
+               REDEBUG("Unable to queue packet - connections at maximum capacity");
+       fail:
                fr_assert(!u->rr && !u->packet);        /* Should not have been fed to the muxer */
                fr_trunk_request_free(&treq);           /* Return to the free list */
-       fail:
                talloc_free(r);
                RETURN_MODULE_FAIL;
-       }
 
-       /*
-        *      All destinations are down.
-        */
-       if (q == FR_TRUNK_ENQUEUE_IN_BACKLOG) {
-               RDEBUG("All destinations are down - cannot send packet");
-               fr_trunk_request_signal_cancel(treq);
+       case FR_TRUNK_ENQUEUE_DST_UNAVAILABLE:
+               REDEBUG("All destinations are down - cannot send packet");
+               goto fail;
+
+       case FR_TRUNK_ENQUEUE_FAIL:
+               REDEBUG("Unable to queue packet");
                goto fail;
        }