diff options
Diffstat (limited to 'src/common/compat_libevent.c')
-rw-r--r-- | src/common/compat_libevent.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/common/compat_libevent.c b/src/common/compat_libevent.c index 250fa2bdb7..2ae280e669 100644 --- a/src/common/compat_libevent.c +++ b/src/common/compat_libevent.c @@ -551,3 +551,27 @@ periodic_timer_free(periodic_timer_t *timer) tor_free(timer); } +#ifdef USE_BUFFEREVENTS +static const struct timeval *one_tick = NULL; +/** + DOCDOC +*/ +const struct timeval *tor_libevent_get_one_tick_timeout(void) +{ + + if (PREDICT_UNLIKELY(one_tick == NULL)) { + struct event_base *base = tor_libevent_get_base(); + struct timeval tv; + if (TOR_LIBEVENT_TICKS_PER_SECOND == 1) { + tv.tv_sec = 1; + tv.tv_usec = 0; + } else { + tv.tv_sec = 0; + tv.tv_usec = 1000000 / TOR_LIBEVENT_TICKS_PER_SECOND; + } + one_tick = event_base_init_common_timeout(base, &tv); + } + return one_tick; +} +#endif + |