Go to the documentation of this file.
47 const int forward_threshold = 86400;
48 const int backward_trigger = 10;
49 time_t real_time = system_time +
now_adj;
53 const time_t overshoot = real_time -
now - 1;
54 if (overshoot > forward_threshold &&
now_adj >= overshoot)
57 real_time -= overshoot;
61 else if (real_time <
now - backward_trigger)
70 const time_t last =
now;
120 gettimeofday(&tv, NULL);
124 struct tm *tm = localtime(&t);
126 buf_printf(&out,
"%04d-%02d-%02d %02d:%02d:%02d",
127 tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
128 tm->tm_hour, tm->tm_min, tm->tm_sec);
130 if (show_usec && tv.tv_usec)
132 buf_printf(&out,
" us=%ld", (
long)tv.tv_usec);
172 if (
now >=
f->reset +
f->per)
177 ret = (++
f->n <=
f->max);
193 for (i = 0; i < 10000; ++i)
196 gettimeofday(&tv, NULL);
198 msg(
M_INFO,
"t=%" PRIi64
" s=%" PRIi64
" us=%ld",
const char * tv_string_abs(const struct timeval *tv, struct gc_arena *gc)
struct buffer alloc_buf_gc(size_t size, struct gc_arena *gc)
#define ALLOC_OBJ(dptr, type)
Wrapper structure for dynamically allocated memory.
Garbage collection arena used to keep track of dynamically allocated memory.
void update_now_usec(struct timeval *tv)
struct frequency_limit * frequency_limit_init(int max, int per)
const char * time_string(time_t t, int usec, bool show_usec, struct gc_arena *gc)
void frequency_limit_free(struct frequency_limit *f)
void update_now(const time_t system_time)
bool buf_printf(struct buffer *buf, const char *format,...)
const char * tv_string(const struct timeval *tv, struct gc_arena *gc)
bool frequency_limit_event_allowed(struct frequency_limit *f)