Removed and guarded pthread specifics for libevent-openssl. Review: https://reviews.apache.org/r/36827
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/2b952a76 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/2b952a76 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/2b952a76 Branch: refs/heads/master Commit: 2b952a76b1bdae58d416768a2608d800cc049937 Parents: 4d4ba02 Author: Joris Van Remoortere <[email protected]> Authored: Wed Jul 29 16:57:27 2015 -0700 Committer: Benjamin Hindman <[email protected]> Committed: Wed Jul 29 16:59:53 2015 -0700 ---------------------------------------------------------------------- 3rdparty/libprocess/src/libevent.cpp | 10 ++++++++++ 3rdparty/libprocess/src/openssl.cpp | 16 +++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/2b952a76/3rdparty/libprocess/src/libevent.cpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/src/libevent.cpp b/3rdparty/libprocess/src/libevent.cpp index 1f175a4..c604caa 100644 --- a/3rdparty/libprocess/src/libevent.cpp +++ b/3rdparty/libprocess/src/libevent.cpp @@ -183,9 +183,19 @@ double EventLoop::time() void EventLoop::initialize() { + // We need to initialize Libevent differently depending on the + // operating system threading support. +#if defined(EVTHREAD_USE_PTHREADS_IMPLEMENTED) if (evthread_use_pthreads() < 0) { LOG(FATAL) << "Failed to initialize, evthread_use_pthreads"; } +#elif defined(EVTHREAD_USE_WINDOWS_THREADS_IMPLEMENTED) + if (evthread_use_windows_threads() < 0) { + LOG(FATAL) << "Failed to initialize, evthread_use_windows_threads"; + } +#else +#error "Libevent must be compiled with either pthread or Windows thread support" +#endif // This enables debugging of libevent calls. We can remove this // when the implementation settles and after we gain confidence. http://git-wip-us.apache.org/repos/asf/mesos/blob/2b952a76/3rdparty/libprocess/src/openssl.cpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/src/openssl.cpp b/3rdparty/libprocess/src/openssl.cpp index 1f68460..9ae5c1f 100644 --- a/3rdparty/libprocess/src/openssl.cpp +++ b/3rdparty/libprocess/src/openssl.cpp @@ -23,6 +23,7 @@ #include <mutex> #include <string> +#include <thread> #include <process/once.hpp> @@ -167,13 +168,14 @@ void locking_function(int mode, int n, const char* /*file*/, int /*line*/) // OpenSSL threading. unsigned long id_function() { - pthread_t pthread = pthread_self(); -#ifdef __APPLE__ - mach_port_t id = pthread_mach_thread_np(pthread); -#else - pthread_t id = pthread; -#endif // __APPLE__ - return static_cast<unsigned long>(id); + static_assert(sizeof(std::thread::id) == sizeof(unsigned long), + "sizeof(std::thread::id) must be equal to sizeof(unsigned long)" + " for std::thread::id to be used as a function for determining " + "a thread id"); + + // We use the std::thread id and convert it to an unsigned long. + const std::thread::id id = std::this_thread::get_id(); + return *reinterpret_cast<const unsigned long*>(&id); }
