Repository: mesos
Updated Branches:
  refs/heads/master a4a23aa4c -> a744bc06e


Added Once guard for Eventloop::initialize.

Review: https://reviews.apache.org/r/36712


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/a744bc06
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/a744bc06
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/a744bc06

Branch: refs/heads/master
Commit: a744bc06e3d8d4945ba61889c015cdf8dac01ef8
Parents: a4a23aa
Author: Jojy Varghese <[email protected]>
Authored: Fri Jul 31 15:51:23 2015 -0700
Committer: Michael Park <[email protected]>
Committed: Fri Jul 31 15:55:44 2015 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/src/libevent.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/a744bc06/3rdparty/libprocess/src/libevent.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/libevent.cpp 
b/3rdparty/libprocess/src/libevent.cpp
index 9d2af55..d7c47fb 100644
--- a/3rdparty/libprocess/src/libevent.cpp
+++ b/3rdparty/libprocess/src/libevent.cpp
@@ -21,6 +21,7 @@
 #include <event2/thread.h>
 
 #include <process/logging.hpp>
+#include <process/once.hpp>
 
 #include <stout/os/signals.hpp>
 #include <stout/synchronized.hpp>
@@ -184,6 +185,12 @@ double EventLoop::time()
 
 void EventLoop::initialize()
 {
+  static Once* initialized = new Once();
+
+  if (initialized->once()) {
+    return;
+  }
+
   // We need to initialize Libevent differently depending on the
   // operating system threading support.
 #if defined(EVTHREAD_USE_PTHREADS_IMPLEMENTED)
@@ -212,6 +219,8 @@ void EventLoop::initialize()
   if (base == NULL) {
     LOG(FATAL) << "Failed to initialize, event_base_new";
   }
+
+  initialized->done();
 }
 
 } // namespace process {

Reply via email to