From: Doug MacEachern Date: Fri, 24 Aug 2001 04:16:57 +0000 (+0000) Subject: only set the crypto locking callback if mpm is threaded X-Git-Tag: 2.0.25~95 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=30354a3b9b03d7febf66f0b4da153468a6d2b60d;p=apache only set the crypto locking callback if mpm is threaded get rid of some warnings introduced by the original patch PR: Obtained from: Submitted by: Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@90614 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/ssl/ssl_util.c b/modules/ssl/ssl_util.c index 46eb14abe2..6c6bfb015b 100644 --- a/modules/ssl/ssl_util.c +++ b/modules/ssl/ssl_util.c @@ -62,6 +62,7 @@ who piss me off!'' -- Calvin */ #include "mod_ssl.h" +#include "ap_mpm.h" /* _________________________________________________________________ ** @@ -335,7 +336,8 @@ ssl_util_getmodconfig_ssl( static apr_lock_t *lock_cs[CRYPTO_NUM_LOCKS]; static long lock_count[CRYPTO_NUM_LOCKS]; -void ssl_util_thread_locking_callback(int mode, int type, char *file, int line) +static void ssl_util_thread_locking_callback(int mode, int type, + const char *file, int line) { if (mode & CRYPTO_LOCK) { apr_lock_acquire(lock_cs[type]); @@ -346,31 +348,47 @@ void ssl_util_thread_locking_callback(int mode, int type, char *file, int line) } } -apr_status_t ssl_util_thread_cleanup(void *data) +static apr_status_t ssl_util_thread_cleanup(void *data) { int i; CRYPTO_set_locking_callback(NULL); - for (i = 0; i < CRYPTO_NUM_LOCKS; i++) + + for (i = 0; i < CRYPTO_NUM_LOCKS; i++) { apr_lock_destroy(lock_cs[i]); + } + return APR_SUCCESS; } void ssl_util_thread_setup(server_rec *s, apr_pool_t *p) { - int i; + int i, threaded_mpm; SSLModConfigRec *mc = myModConfig(s); + ap_mpm_query(AP_MPMQ_IS_THREADED, &threaded_mpm); + + if (!threaded_mpm) { + return; + } + *lock_cs = apr_palloc(p, CRYPTO_NUM_LOCKS); - for (i = 0; i < CRYPTO_NUM_LOCKS; i++) - { + + /* + * XXX: CRYPTO_NUM_LOCKS == 28 + * should determine if there are lock types we do not need + * for example: debug_malloc, debug_malloc2 (see crypto/cryptlib.c) + */ + for (i = 0; i < CRYPTO_NUM_LOCKS; i++) { lock_count[i]=0; apr_lock_create(&(lock_cs[i]), APR_MUTEX, APR_LOCKALL, - mc->szMutexFile, p); + mc->szMutexFile, p); } - CRYPTO_set_locking_callback((void (*)())ssl_util_thread_locking_callback); + CRYPTO_set_locking_callback(ssl_util_thread_locking_callback); + apr_pool_cleanup_register(p, NULL, - ssl_util_thread_cleanup, apr_pool_cleanup_null); + ssl_util_thread_cleanup, + apr_pool_cleanup_null); }