48 const int forward_threshold = 86400;
50 const int backward_trigger = 10;
51 time_t real_time = system_time +
now_adj;
55 const time_t overshoot = real_time -
now - 1;
56 if (overshoot > forward_threshold &&
now_adj >= overshoot)
59 real_time -= overshoot;
63 else if (real_time <
now - backward_trigger)
72 const time_t last =
now;
122 gettimeofday(&tv, NULL);
126 struct tm *tm = localtime(&t);
128 buf_printf(&out,
"%04d-%02d-%02d %02d:%02d:%02d",
129 tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
130 tm->tm_hour, tm->tm_min, tm->tm_sec);
132 if (show_usec && tv.tv_usec)
134 buf_printf(&out,
" us=%ld", (
long)tv.tv_usec);
179 ret = (++f->
n <= f->
max);
195 for (i = 0; i < 10000; ++i)
198 gettimeofday(&tv, NULL);
200 msg(
M_INFO,
"t=%" PRIi64
" s=%" PRIi64
" us=%ld",
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.