Chromium Code Reviews| Index: third_party/libevent/event.c |
| diff --git a/third_party/libevent/event.c b/third_party/libevent/event.c |
| index 125335207d518eb63b6ef0e60453221041d90b92..81d706fe6444a3b1cc6ef63e15ffc2f9b049c816 100644 |
| --- a/third_party/libevent/event.c |
| +++ b/third_party/libevent/event.c |
| @@ -107,7 +107,7 @@ static const struct eventop *eventops[] = { |
| /* Global state */ |
| struct event_base *current_base = NULL; |
| extern struct event_base *evsignal_base; |
| -static int use_monotonic; |
| +static int no_monotonic_clock = 0; |
|
jln (very slow on Chromium)
2014/04/09 20:13:09
Isn't it more clear to keep this as "use_monotonic
agl
2014/04/09 20:25:20
Yea, fair point. I was just aiming for it to be BS
|
| /* Prototypes */ |
| static void event_queue_insert(struct event_base *, struct event *, int); |
| @@ -120,17 +120,6 @@ static int timeout_next(struct event_base *, struct timeval **); |
| static void timeout_process(struct event_base *); |
| static void timeout_correct(struct event_base *, struct timeval *); |
| -static void |
| -detect_monotonic(void) |
| -{ |
| -#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC) |
| - struct timespec ts; |
| - |
| - if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) |
| - use_monotonic = 1; |
| -#endif |
| -} |
| - |
| static int |
| gettime(struct event_base *base, struct timeval *tp) |
| { |
| @@ -140,18 +129,18 @@ gettime(struct event_base *base, struct timeval *tp) |
| } |
| #if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC) |
| - if (use_monotonic) { |
| - struct timespec ts; |
| - |
| - if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1) |
| - return (-1); |
| + struct timespec ts; |
| + if (no_monotonic_clock == 0 && |
| + clock_gettime(CLOCK_MONOTONIC, &ts) == 0) { |
| tp->tv_sec = ts.tv_sec; |
| tp->tv_usec = ts.tv_nsec / 1000; |
| return (0); |
| } |
| #endif |
| + no_monotonic_clock = 1; |
| + |
| return (evutil_gettimeofday(tp, NULL)); |
| } |
| @@ -175,7 +164,6 @@ event_base_new(void) |
| if ((base = calloc(1, sizeof(struct event_base))) == NULL) |
| event_err(1, "%s: calloc", __func__); |
| - detect_monotonic(); |
| gettime(base, &base->event_tv); |
| min_heap_ctor(&base->timeheap); |
| @@ -868,7 +856,7 @@ timeout_correct(struct event_base *base, struct timeval *tv) |
| unsigned int size; |
| struct timeval off; |
| - if (use_monotonic) |
| + if (no_monotonic_clock == 0) |
| return; |
| /* Check if time is running backwards */ |