Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(320)

Unified Diff: third_party/libevent/event.c

Issue 231493002: libevent: fix race in the common case. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/libevent/chromium.patch ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/libevent/event.c
diff --git a/third_party/libevent/event.c b/third_party/libevent/event.c
index 125335207d518eb63b6ef0e60453221041d90b92..8b6cae507ce72af195f9a877498fbed992665c9e 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 use_monotonic = 1;
/* 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 (use_monotonic &&
+ clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {
tp->tv_sec = ts.tv_sec;
tp->tv_usec = ts.tv_nsec / 1000;
return (0);
}
#endif
+ use_monotonic = 0;
+
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);
« no previous file with comments | « third_party/libevent/chromium.patch ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698