summaryrefslogtreecommitdiffstats
path: root/modules/ssl/ssl_scache.c
diff options
context:
space:
mode:
authorJoe Orton <jorton@apache.org>2008-02-26 17:57:56 +0100
committerJoe Orton <jorton@apache.org>2008-02-26 17:57:56 +0100
commit735b3b7b43c406fb3bb80249162d2252ae073264 (patch)
treede3de04349fa91dc366dfba8363fb5c14aea667a /modules/ssl/ssl_scache.c
parent* modules/ssl/ssl_scache_memcache.c (mc_session_id2sz): Fix memcache (diff)
downloadapache2-735b3b7b43c406fb3bb80249162d2252ae073264.tar.xz
apache2-735b3b7b43c406fb3bb80249162d2252ae073264.zip
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_scache.c')
-rw-r--r--modules/ssl/ssl_scache.c48
1 files changed, 42 insertions, 6 deletions
diff --git a/modules/ssl/ssl_scache.c b/modules/ssl/ssl_scache.c
index 3d97ee8d16..db4dad12e8 100644
--- a/modules/ssl/ssl_scache.c
+++ b/modules/ssl/ssl_scache.c
@@ -90,6 +90,7 @@ BOOL ssl_scache_store(server_rec *s, UCHAR *id, int idlen,
SSLModConfigRec *mc = myModConfig(s);
unsigned char encoded[SSL_SESSION_MAX_DER], *ptr;
unsigned int len;
+ BOOL rv;
/* Serialise the session. */
len = i2d_SSL_SESSION(sess, NULL);
@@ -102,8 +103,18 @@ BOOL ssl_scache_store(server_rec *s, UCHAR *id, int idlen,
ptr = encoded;
len = i2d_SSL_SESSION(sess, &ptr);
- return mc->sesscache->store(mc->sesscache_context, s, id, idlen,
- expiry, encoded, len);
+ if (mc->sesscache->flags & MODSSL_SESSCACHE_FLAG_NOTMPSAFE) {
+ ssl_mutex_on(s);
+ }
+
+ rv = mc->sesscache->store(mc->sesscache_context, s, id, idlen,
+ expiry, encoded, len);
+
+ if (mc->sesscache->flags & MODSSL_SESSCACHE_FLAG_NOTMPSAFE) {
+ ssl_mutex_off(s);
+ }
+
+ return rv;
}
SSL_SESSION *ssl_scache_retrieve(server_rec *s, UCHAR *id, int idlen,
@@ -113,9 +124,20 @@ SSL_SESSION *ssl_scache_retrieve(server_rec *s, UCHAR *id, int idlen,
unsigned char dest[SSL_SESSION_MAX_DER];
unsigned int destlen = SSL_SESSION_MAX_DER;
MODSSL_D2I_SSL_SESSION_CONST unsigned char *ptr;
-
- if (mc->sesscache->retrieve(mc->sesscache_context, s, id, idlen,
- dest, &destlen, p) == FALSE) {
+ BOOL rv;
+
+ if (mc->sesscache->flags & MODSSL_SESSCACHE_FLAG_NOTMPSAFE) {
+ ssl_mutex_on(s);
+ }
+
+ rv = mc->sesscache->retrieve(mc->sesscache_context, s, id, idlen,
+ dest, &destlen, p);
+
+ if (mc->sesscache->flags & MODSSL_SESSCACHE_FLAG_NOTMPSAFE) {
+ ssl_mutex_off(s);
+ }
+
+ if (rv == FALSE) {
return NULL;
}
@@ -129,9 +151,15 @@ void ssl_scache_remove(server_rec *s, UCHAR *id, int idlen,
{
SSLModConfigRec *mc = myModConfig(s);
+ if (mc->sesscache->flags & MODSSL_SESSCACHE_FLAG_NOTMPSAFE) {
+ ssl_mutex_on(s);
+ }
+
mc->sesscache->delete(mc->sesscache_context, s, id, idlen, p);
- return;
+ if (mc->sesscache->flags & MODSSL_SESSCACHE_FLAG_NOTMPSAFE) {
+ ssl_mutex_off(s);
+ }
}
/* _________________________________________________________________
@@ -153,8 +181,16 @@ static int ssl_ext_status_hook(request_rec *r, int flags)
ap_rputs("</td></tr>\n", r);
ap_rputs("<tr><td bgcolor=\"#ffffff\">\n", r);
+ if (mc->sesscache->flags & MODSSL_SESSCACHE_FLAG_NOTMPSAFE) {
+ ssl_mutex_on(r->server);
+ }
+
mc->sesscache->status(mc->sesscache_context, r, flags, r->pool);
+ if (mc->sesscache->flags & MODSSL_SESSCACHE_FLAG_NOTMPSAFE) {
+ ssl_mutex_off(r->server);
+ }
+
ap_rputs("</td></tr>\n", r);
ap_rputs("</table>\n", r);
return OK;