This is an automated email from the ASF dual-hosted git repository.

duke8253 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 059e92a  ssl handshake fix
059e92a is described below

commit 059e92a2a717a6d44fe553c82f8faf83ca7bcace
Author: Fei Deng <duke8...@gmail.com>
AuthorDate: Fri Feb 8 14:26:32 2019 -0600

    ssl handshake fix
---
 iocore/net/SSLNetVConnection.cc      | 7 +++++++
 src/traffic_server/traffic_server.cc | 5 +++++
 2 files changed, 12 insertions(+)

diff --git a/iocore/net/SSLNetVConnection.cc b/iocore/net/SSLNetVConnection.cc
index 86cc813..14712ee 100644
--- a/iocore/net/SSLNetVConnection.cc
+++ b/iocore/net/SSLNetVConnection.cc
@@ -73,6 +73,8 @@ void SSL_set0_rbio(SSL *ssl, BIO *rbio);
 
 ClassAllocator<SSLNetVConnection> sslNetVCAllocator("sslNetVCAllocator");
 
+bool stop_ssl_handshake = false;
+
 namespace
 {
 /// Callback to get two locks.
@@ -937,9 +939,14 @@ SSLNetVConnection::free(EThread *t)
     THREAD_FREE(this, sslNetVCAllocator, t);
   }
 }
+
 int
 SSLNetVConnection::sslStartHandShake(int event, int &err)
 {
+  if (stop_ssl_handshake) {
+    Debug("ssl", "Stopping handshake due to server shutting down.");
+    return EVENT_ERROR;
+  }
   if (sslHandshakeBeginTime == 0) {
     sslHandshakeBeginTime = Thread::get_hrtime();
     // net_activity will not be triggered until after the handshake
diff --git a/src/traffic_server/traffic_server.cc 
b/src/traffic_server/traffic_server.cc
index 712328b..2b9eaaa 100644
--- a/src/traffic_server/traffic_server.cc
+++ b/src/traffic_server/traffic_server.cc
@@ -173,6 +173,9 @@ static int delay_listen_for_cache_p;
 // Keeps track if the server is in draining state, follows the 
proxy.node.config.draining metric
 bool ts_is_draining = false;
 
+// Flag to stop ssl handshakes during shutdown.
+extern bool stop_ssl_handshake;
+
 AppVersionInfo appVersionInfo; // Build info for this application
 
 static ArgumentDescription argument_descriptions[] = {
@@ -222,6 +225,8 @@ struct AutoStopCont : public Continuation {
   int
   mainEvent(int /* event */, Event * /* e */)
   {
+    stop_ssl_handshake = true;
+
     APIHook *hook = lifecycle_hooks->get(TS_LIFECYCLE_SHUTDOWN_HOOK);
     while (hook) {
       SCOPED_MUTEX_LOCK(lock, hook->m_cont->mutex, this_ethread());

Reply via email to