]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add 'now' parameter
authorAlan T. DeKok <aland@freeradius.org>
Thu, 13 Jul 2017 19:36:52 +0000 (15:36 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 20 Jul 2017 19:30:06 +0000 (15:30 -0400)
functions should avoid calling gettimeofday()

src/modules/rlm_radius/rlm_radius.c
src/modules/rlm_radius/rlm_radius.h

index a19ed76b5b17d43ac8f329e05afd8bc6a6c906b0..dfd295561920e589d1f39a3d03d451a5979720e4 100644 (file)
@@ -232,7 +232,7 @@ static int transport_parse(TALLOC_CTX *ctx, void *out, CONF_ITEM *ci, UNUSED CON
 #endif
 
 // @todo - pass in REQUEST, or maybe request_io_ctx, so we can store these numbers in the rlm_link_t?
-bool rlm_radius_update_delay(struct timeval *start, uint32_t *rt, uint32_t *count, int code, void *client_io_ctx)
+bool rlm_radius_update_delay(struct timeval *start, uint32_t *rt, uint32_t *count, int code, void *client_io_ctx, struct timeval *now)
 {
        uint32_t delay, frac;
        rlm_radius_retry_t const *retry;
@@ -275,13 +275,13 @@ bool rlm_radius_update_delay(struct timeval *start, uint32_t *rt, uint32_t *coun
        /*
         *      Cap delay at MRD
         */
-       if (retry->mrd) {
-               struct timeval now, end;
-               gettimeofday(&now, NULL);
+       if (now && retry->mrd) {
+               struct timeval end;
+
                end = *start;
                end.tv_sec += retry->mrd;
 
-               if (timercmp(&now, &end, >=)) {
+               if (timercmp(now, &end, >=)) {
                        return false;
                }
        }
index bc2bd4824b4d748122b0f868a4931d6a931504ff..c32526dff2c58bf4134e7d5066900643c8be4372 100644 (file)
@@ -87,6 +87,6 @@ typedef struct fr_radius_client_io_t {
 /*
  *     So transports can calculate retransmission timers.
  */
-bool rlm_radius_update_delay(struct timeval *start, uint32_t *rt, uint32_t *count, int code, void *client_io_ctx);
+bool rlm_radius_update_delay(struct timeval *start, uint32_t *rt, uint32_t *count, int code, void *client_io_ctx, struct timeval *now);
 
 #endif /* _RLM_RADIUS_H */