]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add "end" to retry structure
authorAlan T. DeKok <aland@freeradius.org>
Fri, 24 May 2024 14:26:24 +0000 (10:26 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 3 Jun 2024 12:43:45 +0000 (08:43 -0400)
so that we know when the timers will end.

for MDR==0, we forcibly set "end" to one day.  There are very,
very, few reasons for anything to be operating for that long.

src/lib/util/retry.c
src/lib/util/retry.h

index 4dcd6fd6ef3c59d7bea11c3935cfc625ae554d5f..272a27396d91f6715de4580277fb6291bbc303a4 100644 (file)
@@ -44,13 +44,29 @@ void fr_retry_init(fr_retry_t *r, fr_time_t now, fr_retry_config_t const *config
        r->config = config;
        r->count = 1;
        r->start = now;
+       r->end = fr_time_add(now, config->mrd);
        r->updated = now;
 
+       /*
+        *      Ensure that we always have an end time.
+        *
+        *      If there's no MRD. We artificially force the end to a day.  If we're still retrying after
+        *      that, it's likely good reason to give up.  The rest of the server enforces much shorter
+        *      lifetimes on requests.
+        */
+       if (fr_time_cmp(r->start, r->end) == 0) {
+               if (!config->mrc) {
+                       r->end = fr_time_add(now, fr_time_delta_from_sec(86400));
+               } else {
+                       r->end = fr_time_add(now, fr_time_delta_mul(config->mrt, config->mrc));
+               }
+       }
+
        /*
         *      Only 1 retry, the timeout is MRD, not IRT.
         */
        if (config->mrc == 1) {
-               r->next = fr_time_add(now, config->mrd);
+               r->next = r->end;
                r->rt = config->mrd; /* mostly set for debug messages */
                return;
        }
index 0e289f41e9e69e064eff0899fb180e0ab9a534bd..068ae488cd5daa90323dc72cdd016e50fcf5c536 100644 (file)
@@ -41,6 +41,7 @@ typedef struct {
 typedef struct {
        fr_retry_config_t const *config;                //!< master configuration
        fr_time_t               start;                  //!< when we started the retransmission
+       fr_time_t               end;                    //!< when we will end the retransmissions
        fr_time_t               next;                   //!< when the next timer should be set
        fr_time_t               updated;                //!< last update, really a cached "now".
        fr_time_delta_t         rt;                     //!< retransmit interval