Repository: trafficserver Updated Branches: refs/heads/master 7307f0ef5 -> a24232f8c
Consistently use ink_mutex in preference to pthread_mutex. Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/a24232f8 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/a24232f8 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/a24232f8 Branch: refs/heads/master Commit: a24232f8cbac7a042a7386b959342294abaa69fe Parents: 7307f0e Author: James Peach <[email protected]> Authored: Tue Oct 13 21:26:27 2015 -0700 Committer: James Peach <[email protected]> Committed: Tue Oct 13 21:26:27 2015 -0700 ---------------------------------------------------------------------- iocore/net/SSLDynlock.cc | 11 +++++------ iocore/net/SSLUtils.cc | 11 ++++++----- lib/ts/Arena.cc | 3 --- lib/ts/ink_mutex.cc | 3 +++ 4 files changed, 14 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a24232f8/iocore/net/SSLDynlock.cc ---------------------------------------------------------------------- diff --git a/iocore/net/SSLDynlock.cc b/iocore/net/SSLDynlock.cc index 2590649..75d514b 100644 --- a/iocore/net/SSLDynlock.cc +++ b/iocore/net/SSLDynlock.cc @@ -27,11 +27,11 @@ #include "ts/Diags.h" struct CRYPTO_dynlock_value { - CRYPTO_dynlock_value(const char *f, int l) : file(f), line(l) { pthread_mutex_init(&mutex, NULL); } - ~CRYPTO_dynlock_value() { pthread_mutex_destroy(&mutex); } + CRYPTO_dynlock_value(const char *f, int l) : file(f), line(l) { ink_mutex_init(&mutex, NULL); } + ~CRYPTO_dynlock_value() { ink_mutex_destroy(&mutex); } const char *file; int line; - pthread_mutex_t mutex; + ink_mutex mutex; }; struct CRYPTO_dynlock_value * @@ -49,9 +49,9 @@ ssl_dyn_lock_callback(int mode, struct CRYPTO_dynlock_value *value, const char * Debug("v_ssl_lock", "file: %s line: %d", file, line); if (mode & CRYPTO_LOCK) { - pthread_mutex_lock(&value->mutex); + ink_mutex_acquire(&value->mutex); } else if (mode & CRYPTO_UNLOCK) { - pthread_mutex_unlock(&value->mutex); + ink_mutex_release(&value->mutex); } else { Debug("ssl", "invalid SSL locking mode 0x%x", mode); ink_release_assert(0); @@ -62,6 +62,5 @@ void ssl_dyn_destroy_callback(struct CRYPTO_dynlock_value *value, const char *file, int line) { Debug("v_ssl_lock", "file: %s line: %d", file, line); - delete value; } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a24232f8/iocore/net/SSLUtils.cc ---------------------------------------------------------------------- diff --git a/iocore/net/SSLUtils.cc b/iocore/net/SSLUtils.cc index 9559f39..4282bae 100644 --- a/iocore/net/SSLUtils.cc +++ b/iocore/net/SSLUtils.cc @@ -25,6 +25,7 @@ #include "ts/I_Layout.h" #include "P_Net.h" #include "ts/ink_cap.h" +#include "ts/ink_mutex.h" #include "P_OCSPStapling.h" #include "SSLSessionCache.h" #include "SSLDynlock.h" @@ -121,7 +122,7 @@ static int ssl_session_ticket_index = -1; #endif -static pthread_mutex_t *mutex_buf = NULL; +static ink_mutex *mutex_buf = NULL; static bool open_ssl_initialized = false; RecRawStatBlock *ssl_rsb = NULL; @@ -152,9 +153,9 @@ SSL_locking_callback(int mode, int type, const char *file, int line) #endif if (mode & CRYPTO_LOCK) { - pthread_mutex_lock(&mutex_buf[type]); + ink_mutex_acquire(&mutex_buf[type]); } else if (mode & CRYPTO_UNLOCK) { - pthread_mutex_unlock(&mutex_buf[type]); + ink_mutex_release(&mutex_buf[type]); } else { Debug("ssl", "invalid SSL locking mode 0x%x", mode); ink_assert(0); @@ -806,10 +807,10 @@ SSLInitializeLibrary() Debug("ssl", "FIPS_mode: %d", mode); #endif - mutex_buf = (pthread_mutex_t *)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t)); + mutex_buf = (ink_mutex *)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(ink_mutex)); for (int i = 0; i < CRYPTO_num_locks(); i++) { - pthread_mutex_init(&mutex_buf[i], NULL); + ink_mutex_init(&mutex_buf[i], NULL); } CRYPTO_set_locking_callback(SSL_locking_callback); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a24232f8/lib/ts/Arena.cc ---------------------------------------------------------------------- diff --git a/lib/ts/Arena.cc b/lib/ts/Arena.cc index 7981b40..b5c8da6 100644 --- a/lib/ts/Arena.cc +++ b/lib/ts/Arena.cc @@ -32,9 +32,6 @@ #define DEFAULT_ALLOC_SIZE 1024 #define DEFAULT_BLOCK_SIZE (DEFAULT_ALLOC_SIZE - (sizeof(ArenaBlock) - 8)) -// Define the _g_mattr first to avoid static initialization order fiasco. -x_pthread_mutexattr_t _g_mattr; - static Allocator defaultSizeArenaBlock("ArenaBlock", DEFAULT_ALLOC_SIZE); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a24232f8/lib/ts/ink_mutex.cc ---------------------------------------------------------------------- diff --git a/lib/ts/ink_mutex.cc b/lib/ts/ink_mutex.cc index 36a68bd..34fe28d 100644 --- a/lib/ts/ink_mutex.cc +++ b/lib/ts/ink_mutex.cc @@ -27,4 +27,7 @@ #include "stdio.h" #include "ts/ink_mutex.h" +// Define the _g_mattr first to avoid static initialization order fiasco. +x_pthread_mutexattr_t _g_mattr; + ink_mutex __global_death = PTHREAD_MUTEX_INITIALIZER;
