kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject [1/2] kudu git commit: ssl_factory: avoid a non-POD (vector<>) in static storage
Date Mon, 05 Dec 2016 07:26:24 GMT
Repository: kudu
Updated Branches:
  refs/heads/master 47c25ceae -> 0ac14a564


ssl_factory: avoid a non-POD (vector<>) in static storage

The global vector<Mutex*> in static storage was causing ASAN test
failures when I looped rpc-test's keepalive test with SSL enabled[1].
The issue is that the static storage destructor could run concurrently
with other threads still trying to access the SSL mutexes.

Since this mutex list is purposefully leaked anyway, it's better to just
use a C-style array.

[1] http://dist-test.cloudera.org/job?job_id=todd.1480910327.10622

Change-Id: I859aefd932d62fa8619650fcc795d3676187ceb4
Reviewed-on: http://gerrit.cloudera.org:8080/5354
Reviewed-by: Adar Dembo <adar@cloudera.com>
Tested-by: Kudu Jenkins


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

Branch: refs/heads/master
Commit: a6cf13f4a3d448fff0cd049cf18196c20696d940
Parents: 47c25ce
Author: Todd Lipcon <todd@apache.org>
Authored: Mon Dec 5 12:11:24 2016 +0800
Committer: Todd Lipcon <todd@apache.org>
Committed: Mon Dec 5 07:04:28 2016 +0000

----------------------------------------------------------------------
 src/kudu/util/net/ssl_factory.cc | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/a6cf13f4/src/kudu/util/net/ssl_factory.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/net/ssl_factory.cc b/src/kudu/util/net/ssl_factory.cc
index 4fefb45..b8016a4 100644
--- a/src/kudu/util/net/ssl_factory.cc
+++ b/src/kudu/util/net/ssl_factory.cc
@@ -33,14 +33,14 @@ namespace kudu {
 
 // These non-POD elements will be alive for the lifetime of the process, so don't allocate
in
 // static storage.
-static std::vector<Mutex*> ssl_mutexes;
+static Mutex* g_ssl_mutexes;
 
 // Lock/Unlock the nth lock. Only to be used by OpenSSL.
 static void CryptoLockingCallback(int mode, int n, const char* /*unused*/, int /*unused*/)
{
   if (mode & CRYPTO_LOCK) {
-    ssl_mutexes[n]->Acquire();
+    g_ssl_mutexes[n].Acquire();
   } else {
-    ssl_mutexes[n]->Release();
+    g_ssl_mutexes[n].Release();
   }
 }
 
@@ -55,10 +55,8 @@ void DoSSLInit() {
   OpenSSL_add_all_algorithms();
   RAND_poll();
 
-  for (int i = 0; i < CRYPTO_num_locks(); ++i) {
-    debug::ScopedLeakCheckDisabler d;
-    ssl_mutexes.push_back(new Mutex());
-  }
+  debug::ScopedLeakCheckDisabler d;
+  g_ssl_mutexes = new Mutex[CRYPTO_num_locks()];
 
   // Callbacks used by OpenSSL required in a multi-threaded setting.
   CRYPTO_set_locking_callback(CryptoLockingCallback);


Mime
View raw message