]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
trunk: Always re-calculate the connection/request ratio
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 15 May 2020 19:48:17 +0000 (14:48 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 15 May 2020 19:51:10 +0000 (14:51 -0500)
src/lib/server/trunk.c

index 9e5389f4076383ff999b38195a0c36a681f82166..de2dafb14718a8628d680a141225ce10ef5cfe78 100644 (file)
@@ -1695,39 +1695,21 @@ static uint64_t trunk_connection_requests_requeue(fr_trunk_connection_t *tconn,
        }
 
 done:
-       /*
-        *      If the trunk connection was draining,
-        *      its requests weren't counted in the requests
-        *      per connection stats the last time they were
-        *      calculated.  Those requests have now been
-        *      moved onto active connections, so we need to
-        *      update the ratio now.
-        */
-       switch (tconn->pub.state) {
-       case FR_TRUNK_CONN_DRAINING:
-       case FR_TRUNK_CONN_INACTIVE_DRAINING:
 
        /*
-        *      If the trunk connection was active
-        *      it may have been removed from the heap at
-        *      the point the ratio was re-calculated.
+        *      Always re-calculate the request/connection
+        *      ratio at the end.
+        *
+        *      This avoids having the state transition
+        *      functions do it.
         *
-        *      As we've now re-inserted it into the
-        *      heap, we need to update the ratio.
+        *      The ratio would be wrong when they calculated
+        *      it anyway, because a bunch of requests are
+        *      dequeued from the connection and temporarily
+        *      cease to exist from the perspective of the
+        *      trunk_requests_per_connection code.
         */
-       case FR_TRUNK_CONN_ACTIVE:
-               trunk_requests_per_connection(NULL, NULL, trunk, fr_time(), false);
-               break;
-
-       default:
-               /*
-                *      Verify the above logic is correct
-                */
-#ifndef NDEBUG
-               trunk_requests_per_connection(NULL, NULL, trunk, fr_time(), true);
-#endif
-               break;
-       }
+       trunk_requests_per_connection(NULL, NULL, trunk, fr_time(), false);
 
        fr_connection_signals_resume(tconn->pub.conn);
        return moved;