summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorJoe Orton <jorton@apache.org>2008-02-22 12:36:51 +0100
committerJoe Orton <jorton@apache.org>2008-02-22 12:36:51 +0100
commitfb38ad47ec83203151aa2e5cea12fb55d3e755ac (patch)
treee305f11c2d2ac1cc9c0346855e61b49d5fb7bde0 /modules
parent* support/htpasswd.c (seed_rand): Fix compiler warning. (diff)
downloadapache2-fb38ad47ec83203151aa2e5cea12fb55d3e755ac.tar.xz
apache2-fb38ad47ec83203151aa2e5cea12fb55d3e755ac.zip
Re-implement the SSL session cache abstraction using a vtable; first
step towards use of the ap_provider interface: * modules/ssl/ssl_private.h (modssl_sesscache_provider): Add new vtable type. (SSLModConfigRec): Reference the vtable here. Replace all the ssl_scache_* prototypes with provider vtable objects. * modules/ssl/ssl_scache.c (ssl_scache_init, ssl_scache_kill, ssl_scache_retrieve, ssl_scache_store, ssl_scache_remove, ssl_ext_status_hook): Use callbacks from vtable rather than ifdef spaghetti. * modules/ssl/ssl_engine_init.c (ssl_init_ctx_session_cache): Only install the OpenSSL callbacks if a vtable is configured. * modules/ssl/ssl_engine_config.c (ssl_cmd_SSLSessionCache): Set up vtable pointer. * modules/ssl/ssl_scache_dc.c, modules/ssl_scache_mc.c: Adjust to make implementations static, and add vtable definition. * modules/ssl_scache_shmcb.c: Likewise; also move the init one-per-process requirement down here. * modules/ssl_scache_dbm.c: Likewise; also (temporarily) use a local subpool in the store callback. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@630163 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules')
-rw-r--r--modules/ssl/ssl_engine_config.c6
-rw-r--r--modules/ssl/ssl_engine_init.c8
-rw-r--r--modules/ssl/ssl_private.h53
-rw-r--r--modules/ssl/ssl_scache.c105
-rw-r--r--modules/ssl/ssl_scache_dbm.c38
-rw-r--r--modules/ssl/ssl_scache_dc.c23
-rw-r--r--modules/ssl/ssl_scache_memcache.c25
-rw-r--r--modules/ssl/ssl_scache_shmcb.c36
8 files changed, 134 insertions, 160 deletions
diff --git a/modules/ssl/ssl_engine_config.c b/modules/ssl/ssl_engine_config.c
index 7cda7667f4..57bae4d248 100644
--- a/modules/ssl/ssl_engine_config.c
+++ b/modules/ssl/ssl_engine_config.c
@@ -63,7 +63,7 @@ SSLModConfigRec *ssl_config_global_create(server_rec *s)
mc->nSessionCacheDataSize = 0;
mc->pSessionCacheDataMM = NULL;
mc->pSessionCacheDataRMM = NULL;
- mc->tSessionCacheDataTable = NULL;
+ mc->sesscache = NULL;
mc->nMutexMode = SSL_MUTEXMODE_UNSET;
mc->nMutexMech = APR_LOCK_DEFAULT;
mc->szMutexFile = NULL;
@@ -977,6 +977,7 @@ const char *ssl_cmd_SSLSessionCache(cmd_parms *cmd,
}
else if ((arglen > 4) && strcEQn(arg, "dbm:", 4)) {
mc->nSessionCacheMode = SSL_SCMODE_DBM;
+ mc->sesscache = &modssl_sesscache_dbm;
mc->szSessionCacheDataFile = ap_server_root_relative(mc->pPool, arg+4);
if (!mc->szSessionCacheDataFile) {
return apr_psprintf(cmd->pool,
@@ -991,6 +992,7 @@ const char *ssl_cmd_SSLSessionCache(cmd_parms *cmd,
return MODSSL_NO_SHARED_MEMORY_ERROR;
#endif
mc->nSessionCacheMode = SSL_SCMODE_SHMCB;
+ mc->sesscache = &modssl_sesscache_shmcb;
colon = ap_strchr_c(arg, ':');
mc->szSessionCacheDataFile =
ap_server_root_relative(mc->pPool, colon+1);
@@ -1032,6 +1034,7 @@ const char *ssl_cmd_SSLSessionCache(cmd_parms *cmd,
else if ((arglen > 3) && strcEQn(arg, "dc:", 3)) {
#ifdef HAVE_DISTCACHE
mc->nSessionCacheMode = SSL_SCMODE_DC;
+ mc->sesscache = &modssl_sesscache_dc;
mc->szSessionCacheDataFile = apr_pstrdup(mc->pPool, arg+3);
if (!mc->szSessionCacheDataFile) {
return apr_pstrcat(cmd->pool,
@@ -1045,6 +1048,7 @@ const char *ssl_cmd_SSLSessionCache(cmd_parms *cmd,
else if ((arglen > 3) && strcEQn(arg, "memcache:", 9)) {
#ifdef HAVE_SSL_CACHE_MEMCACHE
mc->nSessionCacheMode = SSL_SCMODE_MC;
+ mc->sesscache = &modssl_sesscache_mc;
mc->szSessionCacheDataFile = apr_pstrdup(mc->pPool, arg+9);
if (!mc->szSessionCacheDataFile) {
return apr_pstrcat(cmd->pool,
diff --git a/modules/ssl/ssl_engine_init.c b/modules/ssl/ssl_engine_init.c
index 71a950d31a..39fe17a00a 100644
--- a/modules/ssl/ssl_engine_init.c
+++ b/modules/ssl/ssl_engine_init.c
@@ -492,9 +492,11 @@ static void ssl_init_ctx_session_cache(server_rec *s,
SSL_CTX_set_session_cache_mode(ctx, cache_mode);
- SSL_CTX_sess_set_new_cb(ctx, ssl_callback_NewSessionCacheEntry);
- SSL_CTX_sess_set_get_cb(ctx, ssl_callback_GetSessionCacheEntry);
- SSL_CTX_sess_set_remove_cb(ctx, ssl_callback_DelSessionCacheEntry);
+ if (mc->sesscache) {
+ SSL_CTX_sess_set_new_cb(ctx, ssl_callback_NewSessionCacheEntry);
+ SSL_CTX_sess_set_get_cb(ctx, ssl_callback_GetSessionCacheEntry);
+ SSL_CTX_sess_set_remove_cb(ctx, ssl_callback_DelSessionCacheEntry);
+ }
}
static void ssl_init_ctx_callbacks(server_rec *s,
diff --git a/modules/ssl/ssl_private.h b/modules/ssl/ssl_private.h
index eaac13e6ab..4647375044 100644
--- a/modules/ssl/ssl_private.h
+++ b/modules/ssl/ssl_private.h
@@ -364,6 +364,18 @@ typedef struct {
int non_ssl_request;
} SSLConnRec;
+/* Session cache provider vtable. */
+typedef struct {
+ void (*init)(server_rec *s, apr_pool_t *pool);
+ void (*destroy)(server_rec *s);
+ BOOL (*store)(server_rec *s, UCHAR *id, int idlen,
+ time_t expiry, SSL_SESSION *session);
+ SSL_SESSION *(*retrieve)(server_rec *s, UCHAR *id, int idlen,
+ apr_pool_t *pool);
+ void (*delete)(server_rec *s, UCHAR *id, int idlen, apr_pool_t *pool);
+ void (*status)(request_rec *r, int flags, apr_pool_t *pool);
+} modssl_sesscache_provider;
+
typedef struct {
pid_t pid;
apr_pool_t *pPool;
@@ -374,6 +386,10 @@ typedef struct {
apr_shm_t *pSessionCacheDataMM;
apr_rmm_t *pSessionCacheDataRMM;
void *tSessionCacheDataTable;
+
+ /* The configured provider: */
+ const modssl_sesscache_provider *sesscache;
+
ssl_mutexmode_t nMutexMode;
apr_lockmech_e nMutexMech;
const char *szMutexFile;
@@ -595,38 +611,15 @@ SSL_SESSION *ssl_scache_retrieve(server_rec *, UCHAR *, int, apr_pool_t *);
void ssl_scache_remove(server_rec *, UCHAR *, int,
apr_pool_t *);
-char *ssl_scache_id2sz(UCHAR *, int);
-void ssl_scache_dbm_init(server_rec *, apr_pool_t *);
-void ssl_scache_dbm_kill(server_rec *);
-BOOL ssl_scache_dbm_store(server_rec *, UCHAR *, int,
- time_t, SSL_SESSION *, apr_pool_t *);
-SSL_SESSION *ssl_scache_dbm_retrieve(server_rec *, UCHAR *, int,
- apr_pool_t *);
-void ssl_scache_dbm_remove(server_rec *, UCHAR *, int,
- apr_pool_t *);
-void ssl_scache_dbm_status(request_rec *r, int flags, apr_pool_t *);
-
-void ssl_scache_shmcb_init(server_rec *, apr_pool_t *);
-void ssl_scache_shmcb_kill(server_rec *);
-BOOL ssl_scache_shmcb_store(server_rec *, UCHAR *, int, time_t, SSL_SESSION *);
-SSL_SESSION *ssl_scache_shmcb_retrieve(server_rec *, UCHAR *, int);
-void ssl_scache_shmcb_remove(server_rec *, UCHAR *, int);
-void ssl_scache_shmcb_status(request_rec *r, int flags, apr_pool_t *pool);
-
-void ssl_scache_dc_init(server_rec *, apr_pool_t *);
-void ssl_scache_dc_kill(server_rec *);
-BOOL ssl_scache_dc_store(server_rec *, UCHAR *, int, time_t, SSL_SESSION *);
-SSL_SESSION *ssl_scache_dc_retrieve(server_rec *, UCHAR *, int);
-void ssl_scache_dc_remove(server_rec *, UCHAR *, int);
-void ssl_scache_dc_status(request_rec *r, int flags, apr_pool_t *pool);
+const modssl_sesscache_provider modssl_sesscache_shmcb;
+const modssl_sesscache_provider modssl_sesscache_dbm;
+
+#ifdef HAVE_DISTCACHE
+const modssl_sesscache_provider modssl_sesscache_dc;
+#endif
#ifdef HAVE_SSL_CACHE_MEMCACHE
-void ssl_scache_mc_init(server_rec *, apr_pool_t *);
-void ssl_scache_mc_kill(server_rec *);
-BOOL ssl_scache_mc_store(server_rec *, UCHAR *, int, time_t, SSL_SESSION *);
-SSL_SESSION *ssl_scache_mc_retrieve(server_rec *, UCHAR *, int, apr_pool_t *);
-void ssl_scache_mc_remove(server_rec *, UCHAR *, int);
-void ssl_scache_mc_status(request_rec *r, int flags, apr_pool_t *pool);
+const modssl_sesscache_provider modssl_sesscache_mc;
#endif
/** Proxy Support */
diff --git a/modules/ssl/ssl_scache.c b/modules/ssl/ssl_scache.c
index c54a57d595..efabfe8af6 100644
--- a/modules/ssl/ssl_scache.c
+++ b/modules/ssl/ssl_scache.c
@@ -45,55 +45,21 @@ void ssl_scache_init(server_rec *s, apr_pool_t *p)
* Warn the user that he should use the session cache.
* But we can operate without it, of course.
*/
- if (mc->nSessionCacheMode == SSL_SCMODE_UNSET) {
+ if (mc->sesscache == NULL) {
ap_log_error(APLOG_MARK, APLOG_WARNING, 0, s,
"Init: Session Cache is not configured "
"[hint: SSLSessionCache]");
- mc->nSessionCacheMode = SSL_SCMODE_NONE;
return;
}
- if (mc->nSessionCacheMode == SSL_SCMODE_DBM)
- ssl_scache_dbm_init(s, p);
-#ifdef HAVE_DISTCACHE
- else if (mc->nSessionCacheMode == SSL_SCMODE_DC)
- ssl_scache_dc_init(s, p);
-#endif
-#ifdef HAVE_SSL_CACHE_MEMCACHE
- else if (mc->nSessionCacheMode == SSL_SCMODE_MC)
- ssl_scache_mc_init(s, p);
-#endif
- else if (mc->nSessionCacheMode == SSL_SCMODE_SHMCB) {
- void *data;
- const char *userdata_key = "ssl_scache_init";
-
- apr_pool_userdata_get(&data, userdata_key, s->process->pool);
- if (!data) {
- apr_pool_userdata_set((const void *)1, userdata_key,
- apr_pool_cleanup_null, s->process->pool);
- return;
- }
- ssl_scache_shmcb_init(s, p);
- }
+ mc->sesscache->init(s, p);
}
void ssl_scache_kill(server_rec *s)
{
SSLModConfigRec *mc = myModConfig(s);
- if (mc->nSessionCacheMode == SSL_SCMODE_DBM)
- ssl_scache_dbm_kill(s);
- else if (mc->nSessionCacheMode == SSL_SCMODE_SHMCB)
- ssl_scache_shmcb_kill(s);
-#ifdef HAVE_DISTCACHE
- else if (mc->nSessionCacheMode == SSL_SCMODE_DC)
- ssl_scache_dc_kill(s);
-#endif
-#ifdef HAVE_SSL_CACHE_MEMCACHE
- else if (mc->nSessionCacheMode == SSL_SCMODE_MC)
- ssl_scache_mc_kill(s);
-#endif
- return;
+ mc->sesscache->destroy(s);
}
BOOL ssl_scache_store(server_rec *s, UCHAR *id, int idlen,
@@ -101,42 +67,16 @@ BOOL ssl_scache_store(server_rec *s, UCHAR *id, int idlen,
apr_pool_t *p)
{
SSLModConfigRec *mc = myModConfig(s);
- BOOL rv = FALSE;
-
- if (mc->nSessionCacheMode == SSL_SCMODE_DBM)
- rv = ssl_scache_dbm_store(s, id, idlen, expiry, sess, p);
- else if (mc->nSessionCacheMode == SSL_SCMODE_SHMCB)
- rv = ssl_scache_shmcb_store(s, id, idlen, expiry, sess);
-#ifdef HAVE_DISTCACHE
- else if (mc->nSessionCacheMode == SSL_SCMODE_DC)
- rv = ssl_scache_dc_store(s, id, idlen, expiry, sess);
-#endif
-#ifdef HAVE_SSL_CACHE_MEMCACHE
- else if (mc->nSessionCacheMode == SSL_SCMODE_MC)
- rv = ssl_scache_mc_store(s, id, idlen, expiry, sess);
-#endif
- return rv;
+
+ return mc->sesscache->store(s, id, idlen, expiry, sess);
}
SSL_SESSION *ssl_scache_retrieve(server_rec *s, UCHAR *id, int idlen,
apr_pool_t *p)
{
SSLModConfigRec *mc = myModConfig(s);
- SSL_SESSION *sess = NULL;
-
- if (mc->nSessionCacheMode == SSL_SCMODE_DBM)
- sess = ssl_scache_dbm_retrieve(s, id, idlen, p);
- else if (mc->nSessionCacheMode == SSL_SCMODE_SHMCB)
- sess = ssl_scache_shmcb_retrieve(s, id, idlen);
-#ifdef HAVE_DISTCACHE
- else if (mc->nSessionCacheMode == SSL_SCMODE_DC)
- sess = ssl_scache_dc_retrieve(s, id, idlen);
-#endif
-#ifdef HAVE_SSL_CACHE_MEMCACHE
- else if (mc->nSessionCacheMode == SSL_SCMODE_MC)
- sess = ssl_scache_mc_retrieve(s, id, idlen, p);
-#endif
- return sess;
+
+ return mc->sesscache->retrieve(s, id, idlen, p);
}
void ssl_scache_remove(server_rec *s, UCHAR *id, int idlen,
@@ -144,18 +84,8 @@ void ssl_scache_remove(server_rec *s, UCHAR *id, int idlen,
{
SSLModConfigRec *mc = myModConfig(s);
- if (mc->nSessionCacheMode == SSL_SCMODE_DBM)
- ssl_scache_dbm_remove(s, id, idlen, p);
- else if (mc->nSessionCacheMode == SSL_SCMODE_SHMCB)
- ssl_scache_shmcb_remove(s, id, idlen);
-#ifdef HAVE_DISTCACHE
- else if (mc->nSessionCacheMode == SSL_SCMODE_DC)
- ssl_scache_dc_remove(s, id, idlen);
-#endif
-#ifdef HAVE_SSL_CACHE_MEMCACHE
- else if (mc->nSessionCacheMode == SSL_SCMODE_MC)
- ssl_scache_mc_remove(s, id, idlen);
-#endif
+ mc->sesscache->delete(s, id, idlen, p);
+
return;
}
@@ -166,9 +96,9 @@ void ssl_scache_remove(server_rec *s, UCHAR *id, int idlen,
*/
static int ssl_ext_status_hook(request_rec *r, int flags)
{
- SSLSrvConfigRec *sc = mySrvConfig(r->server);
+ SSLModConfigRec *mc = myModConfig(r->server);
- if (sc == NULL || flags & AP_STATUS_SHORT)
+ if (mc == NULL || flags & AP_STATUS_SHORT)
return OK;
ap_rputs("<hr>\n", r);
@@ -178,18 +108,7 @@ 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 (sc->mc->nSessionCacheMode == SSL_SCMODE_DBM)
- ssl_scache_dbm_status(r, flags, r->pool);
- else if (sc->mc->nSessionCacheMode == SSL_SCMODE_SHMCB)
- ssl_scache_shmcb_status(r, flags, r->pool);
-#ifdef HAVE_DISTCACHE
- else if (sc->mc->nSessionCacheMode == SSL_SCMODE_DC)
- ssl_scache_dc_status(r, flags, r->pool);
-#endif
-#ifdef HAVE_SSL_CACHE_MEMCACHE
- else if (sc->mc->nSessionCacheMode == SSL_SCMODE_MC)
- ssl_scache_mc_status(r, flags, r->pool);
-#endif
+ mc->sesscache->status(r, flags, r->pool);
ap_rputs("</td></tr>\n", r);
ap_rputs("</table>\n", r);
diff --git a/modules/ssl/ssl_scache_dbm.c b/modules/ssl/ssl_scache_dbm.c
index dac480cf26..d84df07b34 100644
--- a/modules/ssl/ssl_scache_dbm.c
+++ b/modules/ssl/ssl_scache_dbm.c
@@ -28,7 +28,10 @@
static void ssl_scache_dbm_expire(server_rec *s);
-void ssl_scache_dbm_init(server_rec *s, apr_pool_t *p)
+static void ssl_scache_dbm_remove(server_rec *s, UCHAR *id, int idlen,
+ apr_pool_t *p);
+
+static void ssl_scache_dbm_init(server_rec *s, apr_pool_t *p)
{
SSLModConfigRec *mc = myModConfig(s);
apr_dbm_t *dbm;
@@ -82,7 +85,7 @@ void ssl_scache_dbm_init(server_rec *s, apr_pool_t *p)
return;
}
-void ssl_scache_dbm_kill(server_rec *s)
+static void ssl_scache_dbm_kill(server_rec *s)
{
SSLModConfigRec *mc = myModConfig(s);
apr_pool_t *p;
@@ -102,9 +105,8 @@ void ssl_scache_dbm_kill(server_rec *s)
return;
}
-BOOL ssl_scache_dbm_store(server_rec *s, UCHAR *id, int idlen,
- time_t expiry, SSL_SESSION *sess,
- apr_pool_t *p)
+static BOOL ssl_scache_dbm_store(server_rec *s, UCHAR *id, int idlen,
+ time_t expiry, SSL_SESSION *sess)
{
SSLModConfigRec *mc = myModConfig(s);
apr_dbm_t *dbm;
@@ -114,6 +116,11 @@ BOOL ssl_scache_dbm_store(server_rec *s, UCHAR *id, int idlen,
int nData;
UCHAR *ucp;
apr_status_t rv;
+ apr_pool_t *p;
+
+ /* ### This is not in any way sane, a persistent pool which gets
+ * cleared each time is needed. */
+ apr_pool_create(&p, s->process->pool);
/* streamline session data */
if ((nData = i2d_SSL_SESSION(sess, NULL)) > sizeof(ucaData)) {
@@ -167,6 +174,7 @@ BOOL ssl_scache_dbm_store(server_rec *s, UCHAR *id, int idlen,
"(store)",
mc->szSessionCacheDataFile);
ssl_mutex_off(s);
+ apr_pool_destroy(p);
free(dbmval.dptr);
return FALSE;
}
@@ -176,11 +184,13 @@ BOOL ssl_scache_dbm_store(server_rec *s, UCHAR *id, int idlen,
mc->szSessionCacheDataFile);
apr_dbm_close(dbm);
ssl_mutex_off(s);
+ apr_pool_destroy(p);
free(dbmval.dptr);
return FALSE;
}
apr_dbm_close(dbm);
ssl_mutex_off(s);
+ apr_pool_destroy(p);
/* free temporary buffers */
free(dbmval.dptr);
@@ -191,8 +201,8 @@ BOOL ssl_scache_dbm_store(server_rec *s, UCHAR *id, int idlen,
return TRUE;
}
-SSL_SESSION *ssl_scache_dbm_retrieve(server_rec *s, UCHAR *id, int idlen,
- apr_pool_t *p)
+static SSL_SESSION *ssl_scache_dbm_retrieve(server_rec *s, UCHAR *id, int idlen,
+ apr_pool_t *p)
{
SSLModConfigRec *mc = myModConfig(s);
apr_dbm_t *dbm;
@@ -267,8 +277,8 @@ SSL_SESSION *ssl_scache_dbm_retrieve(server_rec *s, UCHAR *id, int idlen,
return sess;
}
-void ssl_scache_dbm_remove(server_rec *s, UCHAR *id, int idlen,
- apr_pool_t *p)
+static void ssl_scache_dbm_remove(server_rec *s, UCHAR *id, int idlen,
+ apr_pool_t *p)
{
SSLModConfigRec *mc = myModConfig(s);
apr_dbm_t *dbm;
@@ -416,7 +426,7 @@ static void ssl_scache_dbm_expire(server_rec *s)
return;
}
-void ssl_scache_dbm_status(request_rec *r, int flags, apr_pool_t *p)
+static void ssl_scache_dbm_status(request_rec *r, int flags, apr_pool_t *p)
{
SSLModConfigRec *mc = myModConfig(r->server);
apr_dbm_t *dbm;
@@ -466,3 +476,11 @@ void ssl_scache_dbm_status(request_rec *r, int flags, apr_pool_t *p)
return;
}
+const modssl_sesscache_provider modssl_sesscache_dbm = {
+ ssl_scache_dbm_init,
+ ssl_scache_dbm_kill,
+ ssl_scache_dbm_store,
+ ssl_scache_dbm_retrieve,
+ ssl_scache_dbm_remove,
+ ssl_scache_dbm_status
+};
diff --git a/modules/ssl/ssl_scache_dc.c b/modules/ssl/ssl_scache_dc.c
index b03b0dea4e..4227a34d34 100644
--- a/modules/ssl/ssl_scache_dc.c
+++ b/modules/ssl/ssl_scache_dc.c
@@ -48,7 +48,7 @@
**
*/
-void ssl_scache_dc_init(server_rec *s, apr_pool_t *p)
+static void ssl_scache_dc_init(server_rec *s, apr_pool_t *p)
{
DC_CTX *ctx;
SSLModConfigRec *mc = myModConfig(s);
@@ -88,7 +88,7 @@ void ssl_scache_dc_init(server_rec *s, apr_pool_t *p)
return;
}
-void ssl_scache_dc_kill(server_rec *s)
+static void ssl_scache_dc_kill(server_rec *s)
{
SSLModConfigRec *mc = myModConfig(s);
@@ -97,8 +97,8 @@ void ssl_scache_dc_kill(server_rec *s)
mc->tSessionCacheDataTable = NULL;
}
-BOOL ssl_scache_dc_store(server_rec *s, UCHAR *id, int idlen,
- time_t timeout, SSL_SESSION * pSession)
+static BOOL ssl_scache_dc_store(server_rec *s, UCHAR *id, int idlen,
+ time_t timeout, SSL_SESSION * pSession)
{
unsigned char der[SSL_SESSION_MAX_DER];
int der_len;
@@ -122,7 +122,7 @@ BOOL ssl_scache_dc_store(server_rec *s, UCHAR *id, int idlen,
return TRUE;
}
-SSL_SESSION *ssl_scache_dc_retrieve(server_rec *s, UCHAR *id, int idlen)
+static SSL_SESSION *ssl_scache_dc_retrieve(server_rec *s, UCHAR *id, int idlen, apr_pool_t *p)
{
unsigned char der[SSL_SESSION_MAX_DER];
unsigned int der_len;
@@ -150,7 +150,7 @@ SSL_SESSION *ssl_scache_dc_retrieve(server_rec *s, UCHAR *id, int idlen)
return pSession;
}
-void ssl_scache_dc_remove(server_rec *s, UCHAR *id, int idlen)
+static void ssl_scache_dc_remove(server_rec *s, UCHAR *id, int idlen, apr_pool_t *p)
{
SSLModConfigRec *mc = myModConfig(s);
DC_CTX *ctx = mc->tSessionCacheDataTable;
@@ -163,7 +163,7 @@ void ssl_scache_dc_remove(server_rec *s, UCHAR *id, int idlen)
}
}
-void ssl_scache_dc_status(request_rec *r, int flags, apr_pool_t *pool)
+static void ssl_scache_dc_status(request_rec *r, int flags, apr_pool_t *pool)
{
SSLModConfigRec *mc = myModConfig(r->server);
@@ -173,5 +173,14 @@ void ssl_scache_dc_status(request_rec *r, int flags, apr_pool_t *pool)
" target: <b>%s</b><br>", mc->szSessionCacheDataFile);
}
+const modssl_sesscache_provider modssl_sesscache_dc = {
+ ssl_scache_dc_init,
+ ssl_scache_dc_kill,
+ ssl_scache_dc_store,
+ ssl_scache_dc_retrieve,
+ ssl_scache_dc_remove,
+ ssl_scache_dc_status
+};
+
#endif
diff --git a/modules/ssl/ssl_scache_memcache.c b/modules/ssl/ssl_scache_memcache.c
index 62ceaa38c2..ca97a1f077 100644
--- a/modules/ssl/ssl_scache_memcache.c
+++ b/modules/ssl/ssl_scache_memcache.c
@@ -70,7 +70,7 @@ static apr_memcache_t *memctxt;
#endif
-void ssl_scache_mc_init(server_rec *s, apr_pool_t *p)
+static void ssl_scache_mc_init(server_rec *s, apr_pool_t *p)
{
apr_status_t rv;
int thread_limit = 0;
@@ -158,7 +158,7 @@ void ssl_scache_mc_init(server_rec *s, apr_pool_t *p)
return;
}
-void ssl_scache_mc_kill(server_rec *s)
+static void ssl_scache_mc_kill(server_rec *s)
{
}
@@ -181,8 +181,8 @@ static char *mc_session_id2sz(unsigned char *id, int idlen,
return str;
}
-BOOL ssl_scache_mc_store(server_rec *s, UCHAR *id, int idlen,
- time_t timeout, SSL_SESSION *pSession)
+static BOOL ssl_scache_mc_store(server_rec *s, UCHAR *id, int idlen,
+ time_t timeout, SSL_SESSION *pSession)
{
char buf[MC_KEY_LEN];
char *strkey = NULL;
@@ -221,13 +221,12 @@ BOOL ssl_scache_mc_store(server_rec *s, UCHAR *id, int idlen,
return TRUE;
}
-SSL_SESSION *ssl_scache_mc_retrieve(server_rec *s, UCHAR *id, int idlen,
- apr_pool_t *p)
+static SSL_SESSION *ssl_scache_mc_retrieve(server_rec *s, UCHAR *id, int idlen,
+ apr_pool_t *p)
{
SSL_SESSION *pSession;
MODSSL_D2I_SSL_SESSION_CONST unsigned char *pder;
apr_size_t der_len;
- SSLModConfigRec *mc = myModConfig(s);
char buf[MC_KEY_LEN];
char* strkey = NULL;
apr_status_t rv;
@@ -275,7 +274,7 @@ SSL_SESSION *ssl_scache_mc_retrieve(server_rec *s, UCHAR *id, int idlen,
return pSession;
}
-void ssl_scache_mc_remove(server_rec *s, UCHAR *id, int idlen)
+static void ssl_scache_mc_remove(server_rec *s, UCHAR *id, int idlen, apr_pool_t *p)
{
char buf[MC_KEY_LEN];
char* strkey = NULL;
@@ -297,10 +296,18 @@ void ssl_scache_mc_remove(server_rec *s, UCHAR *id, int idlen)
}
}
-void ssl_scache_mc_status(request_rec *r, int flags, apr_pool_t *pool)
+static void ssl_scache_mc_status(request_rec *r, int flags, apr_pool_t *pool)
{
/* SSLModConfigRec *mc = myModConfig(r->server); */
/* TODO: Make a mod_status handler. meh. */
}
+const modssl_sesscache_provider modssl_sesscache_mc = {
+ ssl_scache_mc_init,
+ ssl_scache_mc_kill,
+ ssl_scache_mc_store,
+ ssl_scache_mc_retrieve,
+ ssl_scache_mc_remove,
+ ssl_scache_mc_status
+};
#endif
diff --git a/modules/ssl/ssl_scache_shmcb.c b/modules/ssl/ssl_scache_shmcb.c
index 8e3e138cde..05235fbde8 100644
--- a/modules/ssl/ssl_scache_shmcb.c
+++ b/modules/ssl/ssl_scache_shmcb.c
@@ -173,7 +173,7 @@ static BOOL shmcb_subcache_remove(server_rec *, SHMCBHeader *, SHMCBSubcache *,
* subcache internals are deferred to shmcb_subcache_*** functions lower down
*/
-void ssl_scache_shmcb_init(server_rec *s, apr_pool_t *p)
+static void ssl_scache_shmcb_init(server_rec *s, apr_pool_t *p)
{
SSLModConfigRec *mc = myModConfig(s);
void *shm_segment;
@@ -182,6 +182,18 @@ void ssl_scache_shmcb_init(server_rec *s, apr_pool_t *p)
SHMCBHeader *header;
unsigned int num_subcache, num_idx, loop;
+ {
+ void *data;
+ const char *userdata_key = "ssl_scache_init";
+
+ apr_pool_userdata_get(&data, userdata_key, s->process->pool);
+ if (!data) {
+ apr_pool_userdata_set((const void *)1, userdata_key,
+ apr_pool_cleanup_null, s->process->pool);
+ return;
+ }
+ }
+
/* Create shared memory segment */
if (mc->szSessionCacheDataFile == NULL) {
ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
@@ -296,7 +308,7 @@ void ssl_scache_shmcb_init(server_rec *s, apr_pool_t *p)
mc->tSessionCacheDataTable = shm_segment;
}
-void ssl_scache_shmcb_kill(server_rec *s)
+static void ssl_scache_shmcb_kill(server_rec *s)
{
SSLModConfigRec *mc = myModConfig(s);
@@ -307,8 +319,8 @@ void ssl_scache_shmcb_kill(server_rec *s)
return;
}
-BOOL ssl_scache_shmcb_store(server_rec *s, UCHAR *id, int idlen,
- time_t timeout, SSL_SESSION * pSession)
+static BOOL ssl_scache_shmcb_store(server_rec *s, UCHAR *id, int idlen,
+ time_t timeout, SSL_SESSION * pSession)
{
SSLModConfigRec *mc = myModConfig(s);
BOOL to_return = FALSE;
@@ -351,7 +363,8 @@ done:
return to_return;
}
-SSL_SESSION *ssl_scache_shmcb_retrieve(server_rec *s, UCHAR *id, int idlen)
+static SSL_SESSION *ssl_scache_shmcb_retrieve(server_rec *s, UCHAR *id, int idlen,
+ apr_pool_t *p)
{
SSLModConfigRec *mc = myModConfig(s);
SSL_SESSION *pSession = NULL;
@@ -381,7 +394,7 @@ done:
return pSession;
}
-void ssl_scache_shmcb_remove(server_rec *s, UCHAR *id, int idlen)
+static void ssl_scache_shmcb_remove(server_rec *s, UCHAR *id, int idlen, apr_pool_t *p)
{
SSLModConfigRec *mc = myModConfig(s);
SHMCBHeader *header = mc->tSessionCacheDataTable;
@@ -406,7 +419,7 @@ done:
ssl_mutex_off(s);
}
-void ssl_scache_shmcb_status(request_rec *r, int flags, apr_pool_t *p)
+static void ssl_scache_shmcb_status(request_rec *r, int flags, apr_pool_t *p)
{
server_rec *s = r->server;
SSLModConfigRec *mc = myModConfig(s);
@@ -736,3 +749,12 @@ static BOOL shmcb_subcache_remove(server_rec *s, SHMCBHeader *header,
return to_return;
}
+
+const modssl_sesscache_provider modssl_sesscache_shmcb = {
+ ssl_scache_shmcb_init,
+ ssl_scache_shmcb_kill,
+ ssl_scache_shmcb_store,
+ ssl_scache_shmcb_retrieve,
+ ssl_scache_shmcb_remove,
+ ssl_scache_shmcb_status
+};