summaryrefslogtreecommitdiff
path: root/modules/ssl/ssl_engine_mutex.c
diff options
context:
space:
mode:
authorJoe Orton <jorton@apache.org>2008-02-26 16:57:56 +0000
committerJoe Orton <jorton@apache.org>2008-02-26 16:57:56 +0000
commit735b3b7b43c406fb3bb80249162d2252ae073264 (patch)
treede3de04349fa91dc366dfba8363fb5c14aea667a /modules/ssl/ssl_engine_mutex.c
parentd9630b2bec12ab6b41771eed19af0146d9dffa20 (diff)
downloadhttpd-735b3b7b43c406fb3bb80249162d2252ae073264.tar.gz
Session cache interface redesign, Part 6:
Move mutex handling up out of the session cache providers: * modules/ssl/ssl_private.h (modssl_sesscache_provider): Add name and flags fields. Define MODSSL_SESSCACHE_FLAG_NOTMPSAFE constant. * modules/ssl/ssl_scache.c (ssl_scache_store, ssl_scache_retrieve, ssl_scache_remove, ssl_ext_status_hook): Lock and release the mutex around provider calls, if necessary. * modules/ssl/ssl_engine_mutex.c (ssl_mutex_init): Do nothing if no session cache is configured, or the session cache does not require a mutex. Otherwise, fail if no mutex is configured and the session cache *does* require a mutex. (ssl_mutex_on, ssl_mutex_off): Remove checks for mutex mode; functions now invoked only if necessary. * modules/ssl/ssl_scache_dc.c, modules/ssl/ssl_scache_memcache: Set name and flags fields in provider structures. * modules/ssl/ssl_scache_shmcb.c, modules/ssl_scache_dbm.c: Remove mutex handling through; set name and flags fields in provider structures; mark both as unsafe for concurrent access in flags. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@631297 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules/ssl/ssl_engine_mutex.c')
-rw-r--r--modules/ssl/ssl_engine_mutex.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/modules/ssl/ssl_engine_mutex.c b/modules/ssl/ssl_engine_mutex.c
index bbcd92ad64..7c6145cbcd 100644
--- a/modules/ssl/ssl_engine_mutex.c
+++ b/modules/ssl/ssl_engine_mutex.c
@@ -39,12 +39,24 @@ int ssl_mutex_init(server_rec *s, apr_pool_t *p)
SSLModConfigRec *mc = myModConfig(s);
apr_status_t rv;
- if (mc->nMutexMode == SSL_MUTEXMODE_NONE)
+ /* A mutex is only needed if a session cache is configured, and
+ * the provider used is not internally multi-process/thread
+ * safe. */
+ if (!mc->sesscache
+ || (mc->sesscache->flags & MODSSL_SESSCACHE_FLAG_NOTMPSAFE) == 0) {
return TRUE;
+ }
if (mc->pMutex) {
return TRUE;
}
+ else if (mc->nMutexMode == SSL_MUTEXMODE_NONE) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
+ "An SSLMutex is required for the '%s' session cache",
+ mc->sesscache->name);
+ return FALSE;
+ }
+
if ((rv = apr_global_mutex_create(&mc->pMutex, mc->szMutexFile,
mc->nMutexMech, s->process->pool))
!= APR_SUCCESS) {
@@ -97,8 +109,6 @@ int ssl_mutex_on(server_rec *s)
SSLModConfigRec *mc = myModConfig(s);
apr_status_t rv;
- if (mc->nMutexMode == SSL_MUTEXMODE_NONE)
- return TRUE;
if ((rv = apr_global_mutex_lock(mc->pMutex)) != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_WARNING, rv, s,
"Failed to acquire SSL session cache lock");
@@ -112,8 +122,6 @@ int ssl_mutex_off(server_rec *s)
SSLModConfigRec *mc = myModConfig(s);
apr_status_t rv;
- if (mc->nMutexMode == SSL_MUTEXMODE_NONE)
- return TRUE;
if ((rv = apr_global_mutex_unlock(mc->pMutex)) != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_WARNING, rv, s,
"Failed to release SSL session cache lock");