47 const int forward_threshold = 86400;
49 const int backward_trigger = 10;
50 time_t real_time = system_time +
now_adj;
54 const time_t overshoot = real_time -
now - 1;
55 if (overshoot > forward_threshold &&
now_adj >= overshoot)
58 real_time -= overshoot;
62 else if (real_time <
now - backward_trigger)
71 const time_t last =
now;
116 gettimeofday(&tv, NULL);
120 struct tm *tm = localtime(&t);
122 buf_printf(&out,
"%04d-%02d-%02d %02d:%02d:%02d", tm->tm_year + 1900, tm->tm_mon + 1,
123 tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
125 if (show_usec && tv.tv_usec)
127 buf_printf(&out,
" us=%ld", (
long)tv.tv_usec);
172 ret = (++f->
n <= f->
max);
188 for (
i = 0;
i < 10000; ++
i)
191 gettimeofday(&tv, NULL);
193 msg(
M_INFO,
"t=%" PRIi64
" s=%" PRIi64
" us=%ld", (int64_t)t, (int64_t)tv.tv_sec,
bool buf_printf(struct buffer *buf, const char *format,...)
struct buffer alloc_buf_gc(size_t size, struct gc_arena *gc)
#define ALLOC_OBJ(dptr, type)
const char * time_string(time_t t, long usec, bool show_usec, struct gc_arena *gc)
struct frequency_limit * frequency_limit_init(int max, int per)
void update_now(const time_t system_time)
void update_now_usec(struct timeval *tv)
void frequency_limit_free(struct frequency_limit *f)
const char * tv_string(const struct timeval *tv, struct gc_arena *gc)
const char * tv_string_abs(const struct timeval *tv, struct gc_arena *gc)
bool frequency_limit_event_allowed(struct frequency_limit *f)
Wrapper structure for dynamically allocated memory.
int len
Length in bytes of the actual content within the allocated memory.
Garbage collection arena used to keep track of dynamically allocated memory.