]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
use fr_time(), which doesn't jump around when NTP changes
authorAlan T. DeKok <aland@freeradius.org>
Wed, 8 Sep 2021 12:35:58 +0000 (08:35 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 8 Sep 2021 12:35:58 +0000 (08:35 -0400)
src/lib/server/log.h

index f6488ca36ae5e221f7f2e813b9013bdf45c7b4d0..1eef10dc183ec3d3641a682692098cf383d61efb 100644 (file)
@@ -521,8 +521,8 @@ do {\
  *
  */
 typedef struct {
-       time_t          now;                    //!< Current time - Here because it avoids repeated stack allocation.
-       time_t          last_complained;        //!< Last time we emitted a log message.
+       fr_time_t       now;                    //!< Current time - Here because it avoids repeated stack allocation.
+       fr_time_t       last_complained;        //!< Last time we emitted a log message.
        unsigned int    repeated;               //!< Number of "skipped" messages.
 } fr_rate_limit_t;
 
@@ -545,7 +545,7 @@ typedef struct {
 #define RATE_LIMIT_LOCAL(_entry, _log, _fmt, ...) \
 do {\
        if (fr_rate_limit_enabled()) {\
-               (_entry)->now = time(NULL);\
+               (_entry)->now = fr_time();\
                if ((_entry)->now != (_entry)->last_complained) {\
                        (_entry)->last_complained = (_entry)->now;\
                        if (((_entry)->repeated > 0) && (((_entry)->now - (_entry)->last_complained) == 1)) { \
@@ -582,7 +582,7 @@ do {\
 #define RATE_LIMIT_LOCAL_ROPTIONAL(_entry, _l_request, _l_global, _fmt, ...) \
 do {\
        if (fr_rate_limit_enabled()) {\
-               (_entry)->now = time(NULL);\
+               (_entry)->now = fr_time();\
                if ((_entry)->now != (_entry)->last_complained) {\
                        (_entry)->last_complained = (_entry)->now;\
                        if (((_entry)->repeated > 0) && (((_entry)->now - (_entry)->last_complained) == 1)) { \