]> granicus.if.org Git - apache/commitdiff
only set the crypto locking callback if mpm is threaded
authorDoug MacEachern <dougm@apache.org>
Fri, 24 Aug 2001 04:16:57 +0000 (04:16 +0000)
committerDoug MacEachern <dougm@apache.org>
Fri, 24 Aug 2001 04:16:57 +0000 (04:16 +0000)
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

modules/ssl/ssl_util.c

index 46eb14abe2ef8683ec451ac2552e50fa188dd96e..6c6bfb015b44bb8079332fb860504aff9e7e0a8b 100644 (file)
@@ -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);
 
 }