26 #elif defined(_MSC_VER) 38 #if TIME_BACKTRACK_PROTECTION 51 const int forward_threshold = 86400;
52 const int backward_trigger = 10;
53 time_t real_time = system_time +
now_adj;
57 const time_t overshoot = real_time -
now - 1;
58 if (overshoot > forward_threshold && now_adj >= overshoot)
61 real_time -= overshoot;
65 else if (real_time <
now - backward_trigger)
67 now_adj += (
now - real_time);
74 const time_t last =
now;
126 gettimeofday(&tv, NULL);
130 struct tm *tm = localtime(&t);
132 buf_printf(&out,
"%04d-%02d-%02d %02d:%02d:%02d",
133 tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
134 tm->tm_hour, tm->tm_min, tm->tm_sec);
136 if (show_usec && tv.tv_usec)
138 buf_printf(&out,
" us=%ld", (
long)tv.tv_usec);
156 ASSERT(max >= 0 && per >= 0);
183 ret = (++f->
n <= f->
max);
199 for (i = 0; i < 10000; ++i)
202 gettimeofday(&tv, NULL);
204 msg(
M_INFO,
"t=%" PRIi64
" s=%" PRIi64
" us=%ld",
#define ALLOC_OBJ(dptr, type)
bool frequency_limit_event_allowed(struct frequency_limit *f)
bool buf_printf(struct buffer *buf, const char *format,...)
const char * tv_string(const struct timeval *tv, struct gc_arena *gc)
const char * time_string(time_t t, int usec, bool show_usec, struct gc_arena *gc)
struct frequency_limit * frequency_limit_init(int max, int per)
void update_now_usec(struct timeval *tv)
const char * tv_string_abs(const struct timeval *tv, struct gc_arena *gc)
Wrapper structure for dynamically allocated memory.
void update_now(const time_t system_time)
struct buffer alloc_buf_gc(size_t size, struct gc_arena *gc)
Garbage collection arena used to keep track of dynamically allocated memory.
void frequency_limit_free(struct frequency_limit *f)