Has anyone done any testing of shmht in 2.0? It quickly stops caching
new sessions for me using Geoff Thorpe's swamp tool.  If anyone does
want to put effort into getting it working, I've attached a patch which
contains some fixes: the conversion to the RMM code was not finished.

I don't really see any point in putting any effort into the shmht code;  
shmcb has been the session cache of choice for a while (and it works
fine in 2.0 by my testing).  I've attached a second patch which removes
shmht completely, which is the patch I'd recommend.  The files
ssl_util_table.[ch] and ssl_scache_shmht.c can be removed after applying
this patch.

Regards,

joe
Index: modules/ssl/config.m4
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/ssl/config.m4,v
retrieving revision 1.12
diff -u -r1.12 config.m4
--- modules/ssl/config.m4       13 Mar 2003 20:36:39 -0000      1.12
+++ modules/ssl/config.m4       20 Mar 2003 16:38:21 -0000
@@ -69,10 +69,8 @@
 ssl_scache.lo dnl
 ssl_scache_dbm.lo dnl
 ssl_scache_shmcb.lo dnl
-ssl_scache_shmht.lo dnl
 ssl_util.lo dnl
 ssl_util_ssl.lo dnl
-ssl_util_table.lo dnl
 "
 dnl #  hook module into the Autoconf mechanism (--enable-ssl option)
 APACHE_MODULE(ssl, [SSL/TLS support (mod_ssl)], $ssl_objs, , no, [
Index: modules/ssl/mod_ssl.h
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/ssl/mod_ssl.h,v
retrieving revision 1.126
diff -u -r1.126 mod_ssl.h
--- modules/ssl/mod_ssl.h       14 Mar 2003 02:20:50 -0000      1.126
+++ modules/ssl/mod_ssl.h       20 Mar 2003 16:38:22 -0000
@@ -112,7 +112,6 @@
 /* mod_ssl headers */
 #include "ssl_expr.h"
 #include "ssl_util_ssl.h"
-#include "ssl_util_table.h"
 
 /* The #ifdef macros are only defined AFTER including the above
  * therefore we cannot include these system files at the top  :-(
@@ -318,8 +317,7 @@
     SSL_SCMODE_UNSET = UNSET,
     SSL_SCMODE_NONE  = 0,
     SSL_SCMODE_DBM   = 1,
-    SSL_SCMODE_SHMHT = 2,
-    SSL_SCMODE_SHMCB = 3
+    SSL_SCMODE_SHMCB = 2
 } ssl_scmode_t;
 
 /*
@@ -402,7 +400,7 @@
     int             nSessionCacheDataSize;
     apr_shm_t      *pSessionCacheDataMM;
     apr_rmm_t      *pSessionCacheDataRMM;
-    apr_table_t    *tSessionCacheDataTable;
+    void           *tSessionCacheDataTable;
     ssl_mutexmode_t nMutexMode;
     apr_lockmech_e  nMutexMech;
     const char     *szMutexFile;
Index: modules/ssl/ssl_engine_config.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/ssl/ssl_engine_config.c,v
retrieving revision 1.73
diff -u -r1.73 ssl_engine_config.c
--- modules/ssl/ssl_engine_config.c     23 Feb 2003 17:12:43 -0000      1.73
+++ modules/ssl/ssl_engine_config.c     20 Mar 2003 16:38:22 -0000
@@ -1021,49 +1021,9 @@
                                 arg+4);
         }
     }
-    else if ((arglen > 6) && strcEQn(arg, "shmht:", 6)) {
-#if !APR_HAS_SHARED_MEMORY
-        return MODSSL_NO_SHARED_MEMORY_ERROR;
-#endif
-        mc->nSessionCacheMode = SSL_SCMODE_SHMHT;
-        colon = ap_strchr_c(arg, ':');
-        mc->szSessionCacheDataFile =
-            ap_server_root_relative(mc->pPool, colon+1);
-        if (!mc->szSessionCacheDataFile) {
-            return apr_psprintf(cmd->pool,
-                                "SSLSessionCache: Invalid cache file path %s",
-                                colon+1);
-        }
-        mc->tSessionCacheDataTable = NULL;
-        mc->nSessionCacheDataSize  = 1024*512; /* 512KB */
-
-        if ((cp = strchr(mc->szSessionCacheDataFile, '('))) {
-            *cp++ = NUL;
-
-            if (!(cp2 = strchr(cp, ')'))) {
-                return "SSLSessionCache: Invalid argument: "
-                       "no closing parenthesis";
-            }
-
-            *cp2 = NUL;
-
-            mc->nSessionCacheDataSize = atoi(cp);
-
-            if (mc->nSessionCacheDataSize < 8192) {
-                return "SSLSessionCache: Invalid argument: "
-                       "size has to be >= 8192 bytes";
-            }
-
-            if (mc->nSessionCacheDataSize >= APR_SHM_MAXSIZE) {
-                return apr_psprintf(cmd->pool,
-                                    "SSLSessionCache: Invalid argument: "
-                                    "size has to be < %d bytes on this "
-                                    "platform", APR_SHM_MAXSIZE);
-            }
-        }
-    }
     else if (((arglen > 4) && strcEQn(arg, "shm:", 4)) ||
-             ((arglen > 6) && strcEQn(arg, "shmcb:", 6))) {
+             ((arglen > 6) && strcEQn(arg, "shmcb:", 6)) ||
+             ((arglen > 6) && strcEQn(arg, "shmht:", 6))) {
 #if !APR_HAS_SHARED_MEMORY
         return MODSSL_NO_SHARED_MEMORY_ERROR;
 #endif
Index: modules/ssl/ssl_scache.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/ssl/ssl_scache.c,v
retrieving revision 1.15
diff -u -r1.15 ssl_scache.c
--- modules/ssl/ssl_scache.c    3 Feb 2003 17:53:13 -0000       1.15
+++ modules/ssl/ssl_scache.c    20 Mar 2003 16:38:22 -0000
@@ -87,8 +87,7 @@
 
     if (mc->nSessionCacheMode == SSL_SCMODE_DBM)
         ssl_scache_dbm_init(s, p);
-    else if ((mc->nSessionCacheMode == SSL_SCMODE_SHMHT) ||
-             (mc->nSessionCacheMode == SSL_SCMODE_SHMCB)) {
+    else if (mc->nSessionCacheMode == SSL_SCMODE_SHMCB) {
         void *data;
         const char *userdata_key = "ssl_scache_init";
 
@@ -98,10 +97,7 @@
                                   apr_pool_cleanup_null, s->process->pool);
             return;
         }
-        if (mc->nSessionCacheMode == SSL_SCMODE_SHMHT)
-            ssl_scache_shmht_init(s, p);
-        else if (mc->nSessionCacheMode == SSL_SCMODE_SHMCB)
-            ssl_scache_shmcb_init(s, p);
+        ssl_scache_shmcb_init(s, p);
     }
 }
 
@@ -111,8 +107,6 @@
 
     if (mc->nSessionCacheMode == SSL_SCMODE_DBM)
         ssl_scache_dbm_kill(s);
-    else if (mc->nSessionCacheMode == SSL_SCMODE_SHMHT)
-        ssl_scache_shmht_kill(s);
     else if (mc->nSessionCacheMode == SSL_SCMODE_SHMCB)
         ssl_scache_shmcb_kill(s);
     return;
@@ -125,8 +119,6 @@
 
     if (mc->nSessionCacheMode == SSL_SCMODE_DBM)
         rv = ssl_scache_dbm_store(s, id, idlen, expiry, sess);
-    else if (mc->nSessionCacheMode == SSL_SCMODE_SHMHT)
-        rv = ssl_scache_shmht_store(s, id, idlen, expiry, sess);
     else if (mc->nSessionCacheMode == SSL_SCMODE_SHMCB)
         rv = ssl_scache_shmcb_store(s, id, idlen, expiry, sess);
     return rv;
@@ -139,8 +131,6 @@
 
     if (mc->nSessionCacheMode == SSL_SCMODE_DBM)
         sess = ssl_scache_dbm_retrieve(s, id, idlen);
-    else if (mc->nSessionCacheMode == SSL_SCMODE_SHMHT)
-        sess = ssl_scache_shmht_retrieve(s, id, idlen);
     else if (mc->nSessionCacheMode == SSL_SCMODE_SHMCB)
         sess = ssl_scache_shmcb_retrieve(s, id, idlen);
     return sess;
@@ -152,8 +142,6 @@
 
     if (mc->nSessionCacheMode == SSL_SCMODE_DBM)
         ssl_scache_dbm_remove(s, id, idlen);
-    else if (mc->nSessionCacheMode == SSL_SCMODE_SHMHT)
-        ssl_scache_shmht_remove(s, id, idlen);
     else if (mc->nSessionCacheMode == SSL_SCMODE_SHMCB)
         ssl_scache_shmcb_remove(s, id, idlen);
     return;
@@ -165,8 +153,6 @@
 
     if (mc->nSessionCacheMode == SSL_SCMODE_DBM)
         ssl_scache_dbm_status(s, p, func, arg);
-    else if (mc->nSessionCacheMode == SSL_SCMODE_SHMHT)
-        ssl_scache_shmht_status(s, p, func, arg);
     else if (mc->nSessionCacheMode == SSL_SCMODE_SHMCB)
         ssl_scache_shmcb_status(s, p, func, arg);
     return;
@@ -178,8 +164,6 @@
 
     if (mc->nSessionCacheMode == SSL_SCMODE_DBM)
         ssl_scache_dbm_expire(s);
-    else if (mc->nSessionCacheMode == SSL_SCMODE_SHMHT)
-        ssl_scache_shmht_expire(s);
     else if (mc->nSessionCacheMode == SSL_SCMODE_SHMCB)
         ssl_scache_shmcb_expire(s);
     return;
Index: modules/ssl/ssl_scache_shmcb.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/ssl/ssl_scache_shmcb.c,v
retrieving revision 1.17
diff -u -r1.17 ssl_scache_shmcb.c
--- modules/ssl/ssl_scache_shmcb.c      3 Feb 2003 17:53:13 -0000       1.17
+++ modules/ssl/ssl_scache_shmcb.c      20 Mar 2003 16:38:22 -0000
@@ -403,7 +403,7 @@
      * now and stealing a member variable the original shared memory
      * cache was using. :-)
      */
-    mc->tSessionCacheDataTable = (table_t *) shm_segment;
+    mc->tSessionCacheDataTable = shm_segment;
     return;
 }
 
@@ -422,13 +422,11 @@
                            time_t timeout, SSL_SESSION * pSession)
 {
     SSLModConfigRec *mc = myModConfig(s);
-    void *shm_segment;
     BOOL to_return = FALSE;
 
-    /* We've kludged our pointer into the other cache's member variable. */
-    shm_segment = (void *) mc->tSessionCacheDataTable;
     ssl_mutex_on(s);
-    if (!shmcb_store_session(s, shm_segment, id, idlen, pSession, timeout))
+    if (!shmcb_store_session(s, mc->tSessionCacheDataTable, id, idlen,
+                             pSession, timeout))
         /* in this cache engine, "stores" should never fail. */
         ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
                      "'shmcb' code was unable to store a "
@@ -445,13 +443,10 @@
 SSL_SESSION *ssl_scache_shmcb_retrieve(server_rec *s, UCHAR *id, int idlen)
 {
     SSLModConfigRec *mc = myModConfig(s);
-    void *shm_segment;
     SSL_SESSION *pSession;
 
-    /* We've kludged our pointer into the other cache's member variable. */
-    shm_segment = (void *) mc->tSessionCacheDataTable;
     ssl_mutex_on(s);
-    pSession = shmcb_retrieve_session(s, shm_segment, id, idlen);
+    pSession = shmcb_retrieve_session(s, mc->tSessionCacheDataTable, id, idlen);
     ssl_mutex_off(s);
     if (pSession)
         ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
@@ -471,8 +466,7 @@
     SSLModConfigRec *mc = myModConfig(s);
     void *shm_segment;
 
-    /* We've kludged our pointer into the other cache's member variable. */
-    shm_segment = (void *) mc->tSessionCacheDataTable;
+    shm_segment = mc->tSessionCacheDataTable;
     ssl_mutex_on(s);
     shmcb_remove_session(s, shm_segment, id, idlen);
     ssl_mutex_off(s);
@@ -501,8 +495,7 @@
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, 
                  "inside ssl_scache_shmcb_status");
 
-    /* We've kludged our pointer into the other cache's member variable. */
-    shm_segment = (void *) mc->tSessionCacheDataTable;
+    shm_segment = mc->tSessionCacheDataTable;
 
     /* Get the header structure. */
     shmcb_get_header(shm_segment, &header);
Index: ssl_util_table.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/ssl/ssl_util_table.c,v
retrieving revision 1.9
diff -u -r1.9 ssl_util_table.c
--- ssl_util_table.c    12 Mar 2003 06:26:22 -0000      1.9
+++ ssl_util_table.c    20 Mar 2003 15:51:16 -0000
@@ -1775,7 +1775,7 @@
     buckets = (table_entry_t **)
                table_p->ta_calloc(table_p->opt_param,
                                   buck_n, sizeof(table_entry_t *));
-    if (table_p->ta_buckets == NULL)
+    if (buckets == NULL)
         return TABLE_ERROR_ALLOC;
     /*
      * run through each of the items in the current table and rehash
Index: ssl_scache_shmht.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/ssl/ssl_scache_shmht.c,v
retrieving revision 1.13
diff -u -r1.13 ssl_scache_shmht.c
--- ssl_scache_shmht.c  3 Feb 2003 17:53:13 -0000       1.13
+++ ssl_scache_shmht.c  20 Mar 2003 15:51:17 -0000
@@ -69,7 +69,11 @@
     SSLModConfigRec *mc = myModConfig((server_rec *)opt_param);
 
     apr_rmm_off_t off = apr_rmm_calloc(mc->pSessionCacheDataRMM, size);
-    return apr_rmm_addr_get(mc->pSessionCacheDataRMM, off);
+
+    if (off)
+        return apr_rmm_addr_get(mc->pSessionCacheDataRMM, off);
+    else
+        return NULL;
 }
 
 static void *ssl_scache_shmht_calloc(void *opt_param,
@@ -79,7 +83,10 @@
 
     apr_rmm_off_t off = apr_rmm_calloc(mc->pSessionCacheDataRMM, (number*size));
 
-    return apr_rmm_addr_get(mc->pSessionCacheDataRMM, off);
+    if (off)
+        return apr_rmm_addr_get(mc->pSessionCacheDataRMM, off);
+    else
+        return NULL;
 }
 
 static void *ssl_scache_shmht_realloc(void *opt_param, void *ptr, size_t size)
@@ -87,7 +94,11 @@
     SSLModConfigRec *mc = myModConfig((server_rec *)opt_param);
 
     apr_rmm_off_t off = apr_rmm_realloc(mc->pSessionCacheDataRMM, ptr, size);
-    return apr_rmm_addr_get(mc->pSessionCacheDataRMM, off);
+
+    if (off)
+        return apr_rmm_addr_get(mc->pSessionCacheDataRMM, off);
+    else
+        return NULL;
 }
 
 static void ssl_scache_shmht_free(void *opt_param, void *ptr)

Reply via email to