Add EVENT_PRECISE_TIMER environment var for selecting precise-but-slow timer

This commit is contained in:
Nick Mathewson 2012-04-23 13:56:00 -04:00
parent f5e4eb05e5
commit a2598ec6bd

15
event.c
View File

@ -559,10 +559,18 @@ event_base_new_with_config(const struct event_config *cfg)
event_warn("%s: calloc", __func__);
return NULL;
}
evutil_configure_monotonic_time_(&base->monotonic_timer,
cfg && (cfg->flags & EVENT_BASE_FLAG_PRECISE_TIMER));
should_check_environment =
!(cfg && (cfg->flags & EVENT_BASE_FLAG_IGNORE_ENV));
{
struct timeval tmp;
int precise_time =
cfg && (cfg->flags & EVENT_BASE_FLAG_PRECISE_TIMER);
if (should_check_environment && !precise_time)
precise_time = evutil_getenv_("EVENT_PRECISE_TIMER") != NULL;
evutil_configure_monotonic_time_(&base->monotonic_timer, precise_time);
gettime(base, &tmp);
}
@ -586,9 +594,6 @@ event_base_new_with_config(const struct event_config *cfg)
base->evbase = NULL;
should_check_environment =
!(cfg && (cfg->flags & EVENT_BASE_FLAG_IGNORE_ENV));
if (cfg) {
memcpy(&base->max_dispatch_time,
&cfg->max_dispatch_interval, sizeof(struct timeval));