]> granicus.if.org Git - libevent/commitdiff
Add a trivial race-fix from Chromium: do not try to re-detect whether we have a monot...
authorNick Mathewson <nickm@torproject.org>
Fri, 11 Sep 2009 18:21:57 +0000 (18:21 +0000)
committerNick Mathewson <nickm@torproject.org>
Fri, 11 Sep 2009 18:21:57 +0000 (18:21 +0000)
svn:r1427

ChangeLog
event.c

index fa69e4a44e48cf43bf1c62da7b72eb6d8b8a76c6..c4df68449a7a0b13067d58d08ade3182e517e918 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -18,6 +18,8 @@ Changes in 2.0.3-alpha:
  o New functions to explicitly reference a socket used by an evhttp object. Patches from David Reiss.
  o When we send a BEV_EVENT_CONNECTED to indicate connected status, we no longer invoke the write callback as well unless we actually wrote data too.
  o If the kernel tells us that there are a negative number of bytes to read from a socket, do not believe it.  Fixes bug 2841177; found by Alexander Pronchenkov.
+ o Do not detect whether we have monotonic clock support every time a new event base is created: instead do it only once.  Patch taken from Chromium.
+
 
 Changes in 2.0.2-alpha:
  o Add a new flag to bufferevents to make all callbacks automatically deferred.
diff --git a/event.c b/event.c
index 5713f62e2fd85aca724fe871b4468c7f85cf1a3a..6a509e3f1b515df25247e1bbc95374a530376f13 100644 (file)
--- a/event.c
+++ b/event.c
@@ -151,9 +151,15 @@ detect_monotonic(void)
 {
 #if defined(_EVENT_HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
        struct timespec ts;
+       static int use_monotonic_initialized = 0;
+
+       if (use_monotonic_initialized)
+               return;
 
        if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
                use_monotonic = 1;
+
+       use_monotonic_initialized = 1;
 #endif
 }