]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Don't re-run garbage collection
authorNick Porter <nick@portercomputing.co.uk>
Mon, 8 Sep 2025 15:31:38 +0000 (16:31 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Wed, 17 Sep 2025 14:06:40 +0000 (15:06 +0100)
`fr_control_message_alloc()` already attempts garbage collection if
allocation from the ring buffer fails, so trying again like this will
potentially result in 3 calls to `fr_control_gc()` when the buffer is
full.

src/lib/io/control.c

index c387efb94255d8a83aedfcd14f2a6a06419e6064..8653e50db33a73173dabb2a91510541bb0961ee0 100644 (file)
@@ -304,18 +304,13 @@ int fr_control_message_push(fr_control_t *c, fr_ring_buffer_t *rb, uint32_t id,
        MPRINT("CONTROL push aq %p\n", c->aq);
 
        /*
-        *      Get a message.  If we can't get one, do garbage
-        *      collection.  Get another, and if that fails, we're
-        *      done.
+        *      Get a message.  The alloc call attempts garbage collection
+        *      if there is not enough free space.
         */
        m = fr_control_message_alloc(c, rb, id, data, data_size);
        if (!m) {
-               (void) fr_control_gc(c, rb);
-               m = fr_control_message_alloc(c, rb, id, data, data_size);
-               if (!m) {
-                       fr_strerror_const("Failed allocating after GC");
-                       return -2;
-               }
+               fr_strerror_const("Failed allocating after GC");
+               return -2;
        }
 
        if (!fr_atomic_queue_push(c->aq, m)) {