]> granicus.if.org Git - apache/commitdiff
The only remaining question ... are nested or strictly unnested locks
authorWilliam A. Rowe Jr <wrowe@apache.org>
Tue, 4 Jun 2002 02:19:33 +0000 (02:19 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Tue, 4 Jun 2002 02:19:33 +0000 (02:19 +0000)
  expected by OpenSSL?  Right now I've left it as _DEFAULT for the platform
  preference.  Very simple code really - the server_rec was superfluous.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@95497 13f79535-47bb-0310-9956-ffa450edef68

modules/ssl/mod_ssl.h
modules/ssl/ssl_engine_init.c
modules/ssl/ssl_util.c

index aedd09390ff564617255f875dc875c8784776458..5999e97ad9ae6f779d0b6089162e76b93f34c330 100644 (file)
@@ -720,7 +720,7 @@ BOOL         ssl_util_path_check(ssl_pathcheck_t, const char *, apr_pool_t *);
 ssl_algo_t   ssl_util_algotypeof(X509 *, EVP_PKEY *); 
 char        *ssl_util_algotypestr(ssl_algo_t);
 char        *ssl_util_ptxtsub(apr_pool_t *, const char *, const char *, char *);
-void         ssl_util_thread_setup(server_rec *, apr_pool_t *);
+void         ssl_util_thread_setup(apr_pool_t *);
 
 #define APR_SHM_MAXSIZE (64 * 1024 * 1024)
 #endif /* __MOD_SSL_H__ */
index 8161ef5eb418a4ebae24a0b42fc7b054d8cf23f3..7116bea1cd1b821ffe0af4cc550cccef203b046a 100644 (file)
@@ -260,7 +260,7 @@ int ssl_init_Module(apr_pool_t *p, apr_pool_t *plog,
     ssl_init_SSLLibrary(base_server);
 
 #if APR_HAS_THREADS
-    ssl_util_thread_setup(base_server, p);
+    ssl_util_thread_setup(p);
 #endif
 
     /*
index 2147473638e67753d15acd26a13f958b08df2ab9..9b208b404fa334551f93fae3d315e4d91a2a98fc 100644 (file)
@@ -400,20 +400,18 @@ const char *ssl_asn1_table_keyfmt(apr_pool_t *p,
  */
 
 static apr_thread_mutex_t **lock_cs;
-/* FIXME: CRYPTO_NUM_LOCKS may vary between releases - replace with
-   CRYPT_num_locks() [Ben, Jan 2002] */
-static long                 lock_count[CRYPTO_NUM_LOCKS];
+static int                  lock_num_locks;
 
 static void ssl_util_thr_lock(int mode, int type,
-                              MODSSL_CRYPTO_CB_ARG_TYPE *file,
-                              int line)
+                              const char *file, int line)
 {
-    if (mode & CRYPTO_LOCK) {
-        apr_thread_mutex_lock(lock_cs[type]);
-        lock_count[type]++;
-    }
-    else {
-        apr_thread_mutex_unlock(lock_cs[type]);
+    if (type < lock_num_locks) {
+        if (mode & CRYPTO_LOCK) {
+            apr_thread_mutex_lock(lock_cs[type]);
+        }
+        else {
+            apr_thread_mutex_unlock(lock_cs[type]);
+        }
     }
 }
 
@@ -437,41 +435,21 @@ static unsigned long ssl_util_thr_id(void)
 
 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++) {
-        apr_thread_mutex_destroy(lock_cs[i]);
-    }
-
+    /* Let the registered mutex cleanups do their own thing 
+     */
     return APR_SUCCESS;
 }
 
-void ssl_util_thread_setup(server_rec *s, apr_pool_t *p)
+void ssl_util_thread_setup(apr_pool_t *p)
 {
-    int i, threaded_mpm;
-    /* This variable is not used? -aaron
-    SSLModConfigRec *mc = myModConfig(s);
-    */
-
-    ap_mpm_query(AP_MPMQ_IS_THREADED, &threaded_mpm);
-
-    if (!threaded_mpm) {
-        return;
-    }
+    int i;
 
-    lock_cs = apr_palloc(p, CRYPTO_NUM_LOCKS * sizeof(apr_thread_mutex_t *));
+    lock_num_locks = CRYPTO_num_locks();
+    lock_cs = apr_palloc(p, lock_num_locks * sizeof(*lock_cs));
 
-    /*
-     * 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;
-        /* XXX: Can we remove the lock_count now that apr_thread_mutex_t
-         * can support nested (aka recursive) locks? -aaron */
+    for (i = 0; i < lock_num_locks; i++) {
         apr_thread_mutex_create(&(lock_cs[i]), APR_THREAD_MUTEX_DEFAULT, p);
     }
 
@@ -479,9 +457,7 @@ void ssl_util_thread_setup(server_rec *s, apr_pool_t *p)
 
     CRYPTO_set_locking_callback(ssl_util_thr_lock);
 
-    apr_pool_cleanup_register(p, NULL,
-                              ssl_util_thread_cleanup,
-                              apr_pool_cleanup_null);
-
+    apr_pool_cleanup_register(p, NULL, ssl_util_thread_cleanup,
+                                       apr_pool_cleanup_null);
 }
 #endif