Author: rjung
Date: Sun Aug 27 16:24:08 2017
New Revision: 1806376

URL: http://svn.apache.org/viewvc?rev=1806376&view=rev
Log:
Fix thread local key leak introduced in r1781943.

The leak breaks TC trunk test TestDefaultServletEncoding
which executes more than 2500 APR init/terminate.

Modified:
    tomcat/native/trunk/native/src/ssl.c

Modified: tomcat/native/trunk/native/src/ssl.c
URL: 
http://svn.apache.org/viewvc/tomcat/native/trunk/native/src/ssl.c?rev=1806376&r1=1806375&r2=1806376&view=diff
==============================================================================
--- tomcat/native/trunk/native/src/ssl.c (original)
+++ tomcat/native/trunk/native/src/ssl.c Sun Aug 27 16:24:08 2017
@@ -52,6 +52,7 @@ struct CRYPTO_dynlock_value {
 
 #if ! (defined(WIN32) || defined(WIN64))
 apr_threadkey_t *thread_exit_key;
+static int threadkey_initialized = 0;
 #endif
 #endif
 
@@ -331,6 +332,12 @@ static apr_status_t ssl_init_cleanup(voi
         return APR_SUCCESS;
     ssl_initialized = 0;
 
+#if OPENSSL_VERSION_NUMBER < 0x10100000L && ! (defined(WIN32) || 
defined(WIN64))
+    if (threadkey_initialized) {
+        threadkey_initialized = 0;
+        apr_threadkey_private_delete(thread_exit_key);
+    }
+#endif
     if (tcn_password_callback.cb.obj) {
         JNIEnv *env;
         tcn_get_java_env(&env);
@@ -766,6 +773,7 @@ TCN_IMPLEMENT_CALL(jint, SSL, initialize
         tcn_ThrowAPRException(e, err);
         return (jint)err;
     }
+    threadkey_initialized = 1;
 #endif
     /* Initialize thread support */
     ssl_thread_setup(tcn_global_pool);



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org


Reply via email to