You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by rj...@apache.org on 2016/03/20 11:40:53 UTC
svn commit: r1735860 - /tomcat/native/trunk/native/src/ssl.c
Author: rjung
Date: Sun Mar 20 10:40:53 2016
New Revision: 1735860
URL: http://svn.apache.org/viewvc?rev=1735860&view=rev
Log:
Remove more locking code when compiled against
OpenSSL 1.1.0. Those are all noop there.
Followup to r1734491.
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=1735860&r1=1735859&r2=1735860&view=diff
==============================================================================
--- tomcat/native/trunk/native/src/ssl.c (original)
+++ tomcat/native/trunk/native/src/ssl.c Sun Mar 20 10:40:53 2016
@@ -30,13 +30,14 @@ extern apr_pool_t *tcn_global_pool;
ENGINE *tcn_ssl_engine = NULL;
tcn_pass_cb_t tcn_password_callback;
-/* Global reference to the pool used by the dynamic mutexes */
-static apr_pool_t *dynlockpool = NULL;
-
/* From netty-tcnative */
static jclass byteArrayClass;
static jclass stringClass;
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+/* Global reference to the pool used by the dynamic mutexes */
+static apr_pool_t *dynlockpool = NULL;
+
/* Dynamic lock structure */
struct CRYPTO_dynlock_value {
apr_pool_t *pool;
@@ -44,6 +45,7 @@ struct CRYPTO_dynlock_value {
int line;
apr_thread_mutex_t *mutex;
};
+#endif
/*
* supported_ssl_opts is a bitmask that contains all supported SSL_OP_*
@@ -388,6 +390,7 @@ static unsigned long ssl_thread_id(void)
#endif
}
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
static void ssl_set_thread_id(CRYPTO_THREADID *id)
{
CRYPTO_THREADID_set_numeric(id, ssl_thread_id());
@@ -396,14 +399,10 @@ static void ssl_set_thread_id(CRYPTO_THR
static apr_status_t ssl_thread_cleanup(void *data)
{
UNREFERENCED(data);
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
- CRYPTO_set_locking_callback(NULL);
-#endif
CRYPTO_THREADID_set_callback(NULL);
+ CRYPTO_set_locking_callback(NULL);
CRYPTO_set_dynlock_create_callback(NULL);
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
CRYPTO_set_dynlock_lock_callback(NULL);
-#endif
CRYPTO_set_dynlock_destroy_callback(NULL);
dynlockpool = NULL;
@@ -446,7 +445,6 @@ static struct CRYPTO_dynlock_value *ssl_
using our own pool. */
value->file = apr_pstrdup(p, file);
value->line = line;
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
rv = apr_thread_mutex_create(&(value->mutex), APR_THREAD_MUTEX_DEFAULT,
p);
if (rv != APR_SUCCESS) {
@@ -454,7 +452,6 @@ static struct CRYPTO_dynlock_value *ssl_
apr_pool_destroy(p);
return NULL;
}
-#endif
return value;
}
@@ -462,7 +459,6 @@ static struct CRYPTO_dynlock_value *ssl_
* Dynamic locking and unlocking function
*/
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
static void ssl_dyn_lock_function(int mode, struct CRYPTO_dynlock_value *l,
const char *file, int line)
{
@@ -475,7 +471,6 @@ static void ssl_dyn_lock_function(int mo
apr_thread_mutex_unlock(l->mutex);
}
}
-#endif
/*
* Dynamic lock destruction callback
@@ -484,23 +479,21 @@ static void ssl_dyn_destroy_function(str
const char *file, int line)
{
apr_status_t rv;
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
rv = apr_thread_mutex_destroy(l->mutex);
if (rv != APR_SUCCESS) {
/* TODO log that fprintf(stderr, "Failed to destroy mutex for dynamic lock %s:%d", l->file, l->line); */
}
-#endif
/* Trust that whomever owned the CRYPTO_dynlock_value we were
* passed has no future use for it...
*/
apr_pool_destroy(l->pool);
}
+
static void ssl_thread_setup(apr_pool_t *p)
{
int i;
CRYPTO_THREADID_set_callback(ssl_set_thread_id);
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
ssl_lock_num_locks = CRYPTO_num_locks();
ssl_lock_cs = apr_palloc(p, ssl_lock_num_locks * sizeof(*ssl_lock_cs));
@@ -510,20 +503,18 @@ static void ssl_thread_setup(apr_pool_t
}
CRYPTO_set_locking_callback(ssl_thread_lock);
-#endif
/* Set up dynamic locking scaffolding for OpenSSL to use at its
* convenience.
*/
dynlockpool = p;
CRYPTO_set_dynlock_create_callback(ssl_dyn_create_function);
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
CRYPTO_set_dynlock_lock_callback(ssl_dyn_lock_function);
-#endif
CRYPTO_set_dynlock_destroy_callback(ssl_dyn_destroy_function);
apr_pool_cleanup_register(p, NULL, ssl_thread_cleanup,
apr_pool_cleanup_null);
}
+#endif
static int ssl_rand_choosenum(int l, int h)
{
@@ -692,8 +683,10 @@ TCN_IMPLEMENT_CALL(jint, SSL, initialize
#endif
OPENSSL_load_builtin_modules();
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
/* Initialize thread support */
ssl_thread_setup(tcn_global_pool);
+#endif
#ifndef OPENSSL_NO_ENGINE
if (J2S(engine)) {
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org