Commit 92714a6e authored by William A. Rowe Jr's avatar William A. Rowe Jr
Browse files

  The only remaining question ... are nested or strictly unnested locks
  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
parent cf295cab
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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__ */
+1 −1
Original line number Diff line number Diff line
@@ -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

    /*
+18 −42
Original line number Diff line number Diff line
@@ -400,22 +400,20 @@ 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 (type < lock_num_locks) {
        if (mode & CRYPTO_LOCK) {
            apr_thread_mutex_lock(lock_cs[type]);
        lock_count[type]++;
        }
        else {
            apr_thread_mutex_unlock(lock_cs[type]);
        }
    }
}

static unsigned long ssl_util_thr_id(void)
{
@@ -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_register(p, NULL, ssl_util_thread_cleanup,
                                       apr_pool_cleanup_null);

}
#endif