]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
update stats more quickly
authorAlan T. DeKok <aland@freeradius.org>
Sun, 23 Jun 2024 17:05:28 +0000 (13:05 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 24 Jun 2024 02:13:47 +0000 (22:13 -0400)
src/include/radiusd.h
src/main/process.c
src/main/stats.c

index 295e4dcdc06f698ad3a2263bed240bcfd64b150b..bd7276f27e458cbcb19087b3c24e689983a80c42 100644 (file)
@@ -194,9 +194,8 @@ typedef struct main_config {
 typedef enum {
        REQUEST_ACTIVE = 1,
        REQUEST_STOP_PROCESSING,
-       REQUEST_COUNTED
 } rad_master_state_t;
-#define REQUEST_MASTER_NUM_STATES (REQUEST_COUNTED + 1)
+#define REQUEST_MASTER_NUM_STATES (REQUEST_STOP_PROCESSING + 1)
 
 typedef enum {
        REQUEST_QUEUED = 1,
@@ -318,6 +317,7 @@ struct rad_request {
 #define RAD_REQUEST_OPTION_COA         (1 << 0)
 #define RAD_REQUEST_OPTION_CTX                 (1 << 1)
 #define RAD_REQUEST_OPTION_CANCELLED   (1 << 2)
+#define RAD_REQUEST_OPTION_STATS       (1 << 3)
 
 #define SECONDS_PER_DAY                86400
 #define MAX_REQUEST_TIME       30
index 24f7e591b34c386118a010f52e5c930d67ed166b..3cad968806ecd1ca7ad0382f1e3f91d9d2bc4300 100644 (file)
@@ -1006,6 +1006,12 @@ static void request_cleanup_delay_init(REQUEST *request)
 #ifdef HAVE_PTHREAD_H
                rad_assert(request->child_pid == NO_SUCH_CHILD_PID);
 #endif
+
+               /*
+                *      Set the statistics immediately if we can.
+                */
+               request_stats_final(request);
+
                STATE_MACHINE_TIMER(FR_ACTION_TIMER);
                return;
        }
@@ -1256,6 +1262,9 @@ static void request_cleanup_delay(REQUEST *request, int action)
 #ifdef DEBUG_STATE_MACHINE
                        if (rad_debug_lvl) printf("(%u) ********\tNEXT-STATE %s -> %s\n", request->number, __FUNCTION__, "request_cleanup_delay");
 #endif
+
+                       request_stats_final(request);
+
                        STATE_MACHINE_TIMER(FR_ACTION_TIMER);
                        return;
                } /* else it's time to clean up */
index 1cd054e846364b5f460a38760baabaf25d81c16a..6aa908bfeab3781719e3d46310be63e800d5ff49 100644 (file)
@@ -93,7 +93,7 @@ void request_stats_final(REQUEST *request)
        rad_listen_t *listener;
        RADCLIENT *client;
 
-       if (request->master_state == REQUEST_COUNTED) return;
+       if ((request->options & RAD_REQUEST_OPTION_STATS) != 0) return;
 
        /* don't count statistic requests */
        if (request->packet->code == PW_CODE_STATUS_SERVER) {
@@ -353,7 +353,7 @@ void request_stats_final(REQUEST *request)
  done:
 #endif /* WITH_PROXY */
 
-       request->master_state = REQUEST_COUNTED;
+       request->options |= RAD_REQUEST_OPTION_STATS;
 }
 
 typedef struct fr_stats2vp {