trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpe...@apache.org
Subject trafficserver git commit: TS-3156: fix mutex crashes
Date Wed, 12 Nov 2014 18:58:42 GMT
Repository: trafficserver
Updated Branches:
  refs/heads/master 8ab9e25b4 -> 1fc0fd0fe


TS-3156: fix mutex crashes

MUTEX_LOCK and MUTEX_TRY_LOCK expect to be passed a Ptr<ProxyMutex>.
Change direct uses of ProxyMutex to Ptr<ProxyMutex> so the underlying
mutex is not destroyed early.


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

Branch: refs/heads/master
Commit: 1fc0fd0fe9bca2802543ae0a55bb80e8817a6e31
Parents: 8ab9e25
Author: Powell Molleti <powellm@yahoo-inc.com>
Authored: Wed Nov 12 10:54:01 2014 -0800
Committer: James Peach <jpeach@apache.org>
Committed: Wed Nov 12 10:54:01 2014 -0800

----------------------------------------------------------------------
 iocore/net/SSLSessionCache.cc     |  9 +++++----
 iocore/net/SSLSessionCache.h      |  2 +-
 proxy/http/HttpProxyServerMain.cc | 13 ++++++++-----
 3 files changed, 14 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1fc0fd0f/iocore/net/SSLSessionCache.cc
----------------------------------------------------------------------
diff --git a/iocore/net/SSLSessionCache.cc b/iocore/net/SSLSessionCache.cc
index 73b9eaa..eda7387 100644
--- a/iocore/net/SSLSessionCache.cc
+++ b/iocore/net/SSLSessionCache.cc
@@ -121,7 +121,7 @@ void SSLSessionBucket::insertSession(const SSLSessionID &id, SSL_SESSION
*sess)
 
   SSLSession *ssl_session = new SSLSession(id, buf, len);
 
-  MUTEX_TRY_LOCK(lock, &mutex, this_ethread());
+  MUTEX_TRY_LOCK(lock, mutex, this_ethread());
   if (!lock.is_locked()) {
     SSL_INCREMENT_DYN_STAT(ssl_session_cache_lock_contention);
     if (SSLConfigParams::session_cache_skip_on_lock_contention)
@@ -151,7 +151,7 @@ bool SSLSessionBucket::getSession(const SSLSessionID &id,
 
   Debug("ssl.session_cache", "Looking for session with id '%s' in bucket %p", buf, this);
 
-  MUTEX_TRY_LOCK(lock, &mutex, this_ethread());
+  MUTEX_TRY_LOCK(lock, mutex, this_ethread());
   if (!lock.is_locked()) {
    SSL_INCREMENT_DYN_STAT(ssl_session_cache_lock_contention);
    if (SSLConfigParams::session_cache_skip_on_lock_contention)
@@ -213,7 +213,7 @@ void inline SSLSessionBucket::removeOldestSession() {
 }
 
 void SSLSessionBucket::removeSession(const SSLSessionID &id) {
-  MUTEX_LOCK(lock, &mutex, this_ethread()); // We can't bail on contention here because
this session MUST be removed.
+  MUTEX_LOCK(lock, mutex, this_ethread()); // We can't bail on contention here because this
session MUST be removed.
   SSLSession *node = queue.head;
   while (node) {
     if (node->session_id == id)
@@ -227,8 +227,9 @@ void SSLSessionBucket::removeSession(const SSLSessionID &id) {
 
 /* Session Bucket */
 SSLSessionBucket::SSLSessionBucket()
+ : mutex(new ProxyMutex())
 {
-  mutex.init("session_bucket");
+  mutex->init("session_bucket");
 }
 
 SSLSessionBucket::~SSLSessionBucket() {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1fc0fd0f/iocore/net/SSLSessionCache.h
----------------------------------------------------------------------
diff --git a/iocore/net/SSLSessionCache.h b/iocore/net/SSLSessionCache.h
index 38f0fbb..5a6f59b 100644
--- a/iocore/net/SSLSessionCache.h
+++ b/iocore/net/SSLSessionCache.h
@@ -127,7 +127,7 @@ private:
   /* these method must be used while hold the lock */
   void print(const char *) const;
 
-  ProxyMutex mutex;
+  Ptr<ProxyMutex> mutex;
   CountQueue<SSLSession> queue;
 };
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1fc0fd0f/proxy/http/HttpProxyServerMain.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpProxyServerMain.cc b/proxy/http/HttpProxyServerMain.cc
index 4a6be1b..b3ed496 100644
--- a/proxy/http/HttpProxyServerMain.cc
+++ b/proxy/http/HttpProxyServerMain.cc
@@ -43,12 +43,12 @@ HttpSessionAccept *plugin_http_accept = NULL;
 HttpSessionAccept *plugin_http_transparent_accept = 0;
 
 static SLL<SSLNextProtocolAccept> ssl_plugin_acceptors;
-static ProxyMutex ssl_plugin_mutex;
+static Ptr<ProxyMutex> ssl_plugin_mutex;
 
 bool
 ssl_register_protocol(const char * protocol, Continuation * contp)
 {
-  MUTEX_LOCK(lock, &ssl_plugin_mutex, this_ethread());
+  MUTEX_LOCK(lock, ssl_plugin_mutex, this_ethread());
 
   for (SSLNextProtocolAccept * ssl = ssl_plugin_acceptors.head;
         ssl; ssl = ssl_plugin_acceptors.next(ssl)) {
@@ -63,7 +63,7 @@ ssl_register_protocol(const char * protocol, Continuation * contp)
 bool
 ssl_unregister_protocol(const char * protocol, Continuation * contp)
 {
-  MUTEX_LOCK(lock, &ssl_plugin_mutex, this_ethread());
+  MUTEX_LOCK(lock, ssl_plugin_mutex, this_ethread());
 
   for (SSLNextProtocolAccept * ssl = ssl_plugin_acceptors.head;
         ssl; ssl = ssl_plugin_acceptors.next(ssl)) {
@@ -224,7 +224,7 @@ MakeHttpProxyAcceptor(HttpProxyAcceptor& acceptor, HttpProxyPort&
port, unsigned
     }
 #endif
 
-    MUTEX_LOCK(lock, &ssl_plugin_mutex, this_ethread());
+    MUTEX_LOCK(lock, ssl_plugin_mutex, this_ethread());
     ssl_plugin_acceptors.push(ssl);
 
     acceptor._accept = ssl;
@@ -263,7 +263,10 @@ init_HttpProxyServer(int n_accept_threads)
     plugin_http_transparent_accept = new HttpSessionAccept(ha_opt);
     plugin_http_transparent_accept->mutex = new_ProxyMutex();
   }
-  ssl_plugin_mutex.init("SSL Acceptor List");
+  if (ssl_plugin_mutex == NULL) {
+    ssl_plugin_mutex = new ProxyMutex();
+    ssl_plugin_mutex->init("SSL Acceptor List");
+  }
 
   // Do the configuration defined ports.
   for ( int i = 0 , n = proxy_ports.length() ; i < n ; ++i ) {


Mime
View raw message