From: Alan T. DeKok Date: Fri, 24 May 2024 14:26:24 +0000 (-0400) Subject: add "end" to retry structure X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6184537d13ca9d36cf454ce036c81f2445beea9b;p=thirdparty%2Ffreeradius-server.git add "end" to retry structure 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. --- diff --git a/src/lib/util/retry.c b/src/lib/util/retry.c index 4dcd6fd6ef3..272a27396d9 100644 --- a/src/lib/util/retry.c +++ b/src/lib/util/retry.c @@ -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; } diff --git a/src/lib/util/retry.h b/src/lib/util/retry.h index 0e289f41e9e..068ae488cd5 100644 --- a/src/lib/util/retry.h +++ b/src/lib/util/retry.h @@ -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