Sending it again, as I had sent it to the old address earlier.. (sorry if it's a duplicate) Thanks -Madhu -----Original Message----- From: MATHIHALLI,MADHUSUDAN (HP-Cupertino,ex1) [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 23, 2001 10:24 AM To: '[EMAIL PROTECTED]' Subject: [PATCH] towards achieving thread-safetyness in mod_ssl Hi, A first step towards achieving the thread-safetyness of the mod_ssl code - ensure that the SSL library (OpenSSL) has all the locking mechanisms that are needed for thread-safety. It'd be great if somebody could review the code and commit it accordingly.. Pl. let me know your comments / suggestions.. Thanks -Madhu Index: mod_ssl.h =================================================================== RCS file: /home/cvspublic/httpd-2.0/modules/ssl/mod_ssl.h,v retrieving revision 1.27 diff -u -r1.27 mod_ssl.h --- mod_ssl.h 2001/08/22 22:58:07 1.27 +++ mod_ssl.h 2001/08/23 17:03:59 @@ -709,7 +709,7 @@ 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(void); +void ssl_util_thread_setup(server_rec *, apr_pool_t *); apr_status_t ssl_util_setmodconfig(server_rec *, const char *, SSLModConfigRec *); SSLModConfigRec *ssl_util_getmodconfig(server_rec *, const char *); SSLModConfigRec *ssl_util_getmodconfig_ssl(SSL *, const char *); Index: ssl_engine_init.c =================================================================== RCS file: /home/cvspublic/httpd-2.0/modules/ssl/ssl_engine_init.c,v retrieving revision 1.9 diff -u -r1.9 ssl_engine_init.c --- ssl_engine_init.c 2001/08/02 05:25:53 1.9 +++ ssl_engine_init.c 2001/08/23 17:04:00 @@ -185,6 +185,7 @@ ssl_init_SSLLibrary(); } #endif + ssl_util_thread_setup(s, p); if (mc->nInitCount == 1) { ssl_pphrase_Handle(s, p); ssl_init_TmpKeysHandle(SSL_TKP_GEN, s, p); Index: ssl_util.c =================================================================== RCS file: /home/cvspublic/httpd-2.0/modules/ssl/ssl_util.c,v retrieving revision 1.10 diff -u -r1.10 ssl_util.c --- ssl_util.c 2001/08/22 16:21:40 1.10 +++ ssl_util.c 2001/08/23 17:04:00 @@ -328,3 +328,49 @@ return mc; } +/* + * To ensure thread-safetyness in OpenSSL - work in progress + */ + +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) +{ + if (mode & CRYPTO_LOCK) + { + apr_lock_acquire(lock_cs[type]); + lock_count[type]++; + } + else + apr_lock_release(lock_cs[type]); +} + +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_lock_destroy(lock_cs[i]); + return APR_SUCCESS; +} + +void ssl_util_thread_setup(server_rec *s, apr_pool_t *p) +{ + int i; + SSLModConfigRec *mc = myModConfig(s); + + *lock_cs = apr_palloc(p, CRYPTO_NUM_LOCKS); + 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); + } + + CRYPTO_set_locking_callback((void (*)())ssl_util_thread_locking_callback); + apr_pool_cleanup_register(p, NULL, + ssl_util_thread_cleanup, apr_pool_cleanup_null); + +}
FW: [PATCH] towards achieving thread-safetyness in mod_ssl
MATHIHALLI,MADHUSUDAN (HP-Cupertino,ex1) Thu, 23 Aug 2001 10:48:35 -0700
- [PATCH] towards achieving thread-... MATHIHALLI,MADHUSUDAN (HP-Cupertino,ex1)
- Re: [PATCH] towards achievin... Doug MacEachern
- MATHIHALLI,MADHUSUDAN (HP-Cupertino,ex1)
