httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jor...@apache.org
Subject svn commit: r633526 - in /httpd/httpd/trunk/modules/ssl: ssl_private.h ssl_scache.c ssl_scache_dbm.c ssl_scache_dc.c ssl_scache_memcache.c ssl_scache_shmcb.c
Date Tue, 04 Mar 2008 16:14:12 GMT
Author: jorton
Date: Tue Mar  4 08:14:10 2008
New Revision: 633526

URL: http://svn.apache.org/viewvc?rev=633526&view=rev
Log:
Session cache interface redesign, Part 7:

Clean up provider interface, removing use of mod_ssl-specific types:

* modules/ssl/ssl_private.h (modssl_sesscache_provider): Replace BOOL
  with apr_status_t, UCHAR with unsigned char; use 'unsigned int' for
  idlen; constify id arguments; remove pool argument from ->status.

* modules/ssl/ssl_scache_dc.c, modules/ssl/ssl_scache_memcache,
  modules/ssl/ssl_scache_shmcb.c, modules/ssl_scache_dbm.c: Update
  accordingly.

* modules/ssl/ssl_scache.c (ssl_scache_retrieve, ssl_scache_store):
  Adjust for BOOL->apr_status_t change.
  (ssl_ext_status_hook): Update for dropped pool argument.

Modified:
    httpd/httpd/trunk/modules/ssl/ssl_private.h
    httpd/httpd/trunk/modules/ssl/ssl_scache.c
    httpd/httpd/trunk/modules/ssl/ssl_scache_dbm.c
    httpd/httpd/trunk/modules/ssl/ssl_scache_dc.c
    httpd/httpd/trunk/modules/ssl/ssl_scache_memcache.c
    httpd/httpd/trunk/modules/ssl/ssl_scache_shmcb.c

Modified: httpd/httpd/trunk/modules/ssl/ssl_private.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/ssl/ssl_private.h?rev=633526&r1=633525&r2=633526&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/ssl/ssl_private.h (original)
+++ httpd/httpd/trunk/modules/ssl/ssl_private.h Tue Mar  4 08:14:10 2008
@@ -383,24 +383,25 @@
     /* Destroy a given cache context. */    
     void (*destroy)(void *context, server_rec *s);
     /* Store an object in the cache. */
-    BOOL (*store)(void *context, server_rec *s, 
-                  UCHAR *id, int idlen, time_t expiry, 
-                  unsigned char *data, unsigned int datalen);
+    apr_status_t (*store)(void *context, server_rec *s, 
+                          const unsigned char *id, unsigned int idlen, 
+                          time_t expiry, 
+                          unsigned char *data, unsigned int datalen);
     /* Retrieve cached data with key ID of length IDLEN,
      * returning TRUE on success or FALSE otherwise.  If
      * TRUE, the data must be placed in DEST, which has length
      * on entry of *DESTLEN.  *DESTLEN must be updated to 
      * equal the length of data written on exit. */
-    BOOL (*retrieve)(void *context, server_rec *s,
-                     const UCHAR *id, int idlen,
-                     unsigned char *dest, unsigned int *destlen,
-                     apr_pool_t *pool);
+    apr_status_t (*retrieve)(void *context, server_rec *s,
+                             const unsigned char *id, unsigned int idlen,
+                             unsigned char *dest, unsigned int *destlen,
+                             apr_pool_t *pool);
     /* Remove an object from the cache. */
     void (*delete)(void *context, server_rec *s,
-                   UCHAR *id, int idlen, apr_pool_t *pool);
+                   const unsigned char *id, unsigned int idlen,
+                   apr_pool_t *pool);
     /* Dump cache status for mod_status output. */
-    void (*status)(void *context, request_rec *r, 
-                   int flags, apr_pool_t *pool);
+    void (*status)(void *context, request_rec *r, int flags);
 } modssl_sesscache_provider;
 
 typedef struct {

Modified: httpd/httpd/trunk/modules/ssl/ssl_scache.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/ssl/ssl_scache.c?rev=633526&r1=633525&r2=633526&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/ssl/ssl_scache.c (original)
+++ httpd/httpd/trunk/modules/ssl/ssl_scache.c Tue Mar  4 08:14:10 2008
@@ -90,7 +90,7 @@
     SSLModConfigRec *mc = myModConfig(s);
     unsigned char encoded[SSL_SESSION_MAX_DER], *ptr;
     unsigned int len;
-    BOOL rv;
+    apr_status_t rv;
 
     /* Serialise the session. */
     len = i2d_SSL_SESSION(sess, NULL);
@@ -114,7 +114,7 @@
         ssl_mutex_off(s);
     }
 
-    return rv;
+    return rv == APR_SUCCESS ? TRUE : FALSE;
 }
 
 SSL_SESSION *ssl_scache_retrieve(server_rec *s, UCHAR *id, int idlen,
@@ -124,7 +124,7 @@
     unsigned char dest[SSL_SESSION_MAX_DER];
     unsigned int destlen = SSL_SESSION_MAX_DER;
     MODSSL_D2I_SSL_SESSION_CONST unsigned char *ptr;
-    BOOL rv;
+    apr_status_t rv;
 
     if (mc->sesscache->flags & MODSSL_SESSCACHE_FLAG_NOTMPSAFE) {
         ssl_mutex_on(s);
@@ -137,7 +137,7 @@
         ssl_mutex_off(s);
     }
 
-    if (rv == FALSE) {
+    if (rv != APR_SUCCESS) {
         return NULL;
     }
 
@@ -185,7 +185,7 @@
         ssl_mutex_on(r->server);
     }
 
-    mc->sesscache->status(mc->sesscache_context, r, flags, r->pool);
+    mc->sesscache->status(mc->sesscache_context, r, flags);
 
     if (mc->sesscache->flags & MODSSL_SESSCACHE_FLAG_NOTMPSAFE) {
         ssl_mutex_off(r->server);

Modified: httpd/httpd/trunk/modules/ssl/ssl_scache_dbm.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/ssl/ssl_scache_dbm.c?rev=633526&r1=633525&r2=633526&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/ssl/ssl_scache_dbm.c (original)
+++ httpd/httpd/trunk/modules/ssl/ssl_scache_dbm.c Tue Mar  4 08:14:10 2008
@@ -37,7 +37,8 @@
 
 static void ssl_scache_dbm_expire(struct context *ctx, server_rec *s);
 
-static void ssl_scache_dbm_remove(void *context, server_rec *s, UCHAR *id, int idlen,
+static void ssl_scache_dbm_remove(void *context, server_rec *s,
+                                  const unsigned char *id, unsigned int idlen,
                                   apr_pool_t *p);
 
 static const char *ssl_scache_dbm_create(void **context, const char *arg, 
@@ -127,9 +128,10 @@
     return;
 }
 
-static BOOL ssl_scache_dbm_store(void *context, server_rec *s, UCHAR *id, int idlen,
-                                 time_t expiry, 
-                                 unsigned char *ucaData, unsigned int nData)
+static apr_status_t ssl_scache_dbm_store(void *context, server_rec *s, 
+                                         const unsigned char *id, unsigned int idlen,
+                                         time_t expiry, 
+                                         unsigned char *ucaData, unsigned int nData)
 {
     struct context *ctx = context;
     apr_dbm_t *dbm;
@@ -143,14 +145,14 @@
         ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
                  "data size too large for DBM session cache: %d >= %d",
                  (idlen + nData), PAIRMAX);
-        return FALSE;
+        return APR_ENOSPC;
     }
 #else
     if ((idlen + nData) >= 950 /* at least less than approx. 1KB */) {
         ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
                  "data size too large for DBM session cache: %d >= %d",
                  (idlen + nData), 950);
-        return FALSE;
+        return APR_ENOSPC;
     }
 #endif
 
@@ -164,7 +166,7 @@
     if (dbmval.dptr == NULL) {
         ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
                  "malloc error creating DBM value");
-        return FALSE;
+        return APR_ENOMEM;
     }
     memcpy((char *)dbmval.dptr, &expiry, sizeof(time_t));
     memcpy((char *)dbmval.dptr+sizeof(time_t), ucaData, nData);
@@ -179,7 +181,7 @@
                      "(store)",
                      ctx->data_file);
         free(dbmval.dptr);
-        return FALSE;
+        return rv;
     }
     if ((rv = apr_dbm_store(dbm, dbmkey, dbmval)) != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
@@ -187,7 +189,7 @@
                      ctx->data_file);
         apr_dbm_close(dbm);
         free(dbmval.dptr);
-        return FALSE;
+        return rv;
     }
     apr_dbm_close(dbm);
 
@@ -197,12 +199,13 @@
     /* allow the regular expiring to occur */
     ssl_scache_dbm_expire(ctx, s);
 
-    return TRUE;
+    return APR_SUCCESS;
 }
 
-static BOOL ssl_scache_dbm_retrieve(void *context, server_rec *s, const UCHAR *id, int idlen,
-                                    unsigned char *dest, unsigned int *destlen,
-                                    apr_pool_t *p)
+static apr_status_t ssl_scache_dbm_retrieve(void *context, server_rec *s, 
+                                            const unsigned char *id, unsigned int idlen,
+                                            unsigned char *dest, unsigned int *destlen,
+                                            apr_pool_t *p)
 {
     struct context *ctx = context;
     apr_dbm_t *dbm;
@@ -231,23 +234,23 @@
                      "Cannot open SSLSessionCache DBM file `%s' for reading "
                      "(fetch)",
                      ctx->data_file);
-        return FALSE;
+        return rc;
     }
     rc = apr_dbm_fetch(dbm, dbmkey, &dbmval);
     if (rc != APR_SUCCESS) {
         apr_dbm_close(dbm);
-        return FALSE;
+        return rc;
     }
     if (dbmval.dptr == NULL || dbmval.dsize <= sizeof(time_t)) {
         apr_dbm_close(dbm);
-        return FALSE;
+        return rc;
     }
 
     /* parse resulting data */
     nData = dbmval.dsize-sizeof(time_t);
     if (nData > *destlen) {
         apr_dbm_close(dbm);
-        return FALSE;
+        return APR_ENOSPC;
     }    
 
     *destlen = nData;
@@ -259,14 +262,15 @@
     /* make sure the stuff is still not expired */
     now = time(NULL);
     if (expiry <= now) {
-        ssl_scache_dbm_remove(context, s, (UCHAR *)id, idlen, p);
-        return FALSE;
+        ssl_scache_dbm_remove(context, s, id, idlen, p);
+        return APR_EGENERAL;
     }
 
-    return TRUE;
+    return APR_SUCCESS;
 }
 
-static void ssl_scache_dbm_remove(void *context, server_rec *s, UCHAR *id, int idlen,
+static void ssl_scache_dbm_remove(void *context, server_rec *s, 
+                                  const unsigned char *id, unsigned int idlen,
                                   apr_pool_t *p)
 {
     struct context *ctx = context;
@@ -403,8 +407,7 @@
                  nElements, nElements-nDeleted, nDeleted);
 }
 
-static void ssl_scache_dbm_status(void *context, request_rec *r, 
-                                  int flags, apr_pool_t *p)
+static void ssl_scache_dbm_status(void *context, request_rec *r, int flags)
 {
     struct context *ctx = context;
     apr_dbm_t *dbm;

Modified: httpd/httpd/trunk/modules/ssl/ssl_scache_dc.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/ssl/ssl_scache_dc.c?rev=633526&r1=633525&r2=633526&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/ssl/ssl_scache_dc.c (original)
+++ httpd/httpd/trunk/modules/ssl/ssl_scache_dc.c Tue Mar  4 08:14:10 2008
@@ -107,9 +107,10 @@
     }
 }
 
-static BOOL ssl_scache_dc_store(void *context, server_rec *s, UCHAR *id, int idlen,
-                                time_t timeout,
-                                unsigned char *der, unsigned int der_len)
+static apr_status_t ssl_scache_dc_store(void *context, server_rec *s, 
+                                        const unsigned char *id, unsigned int idlen,
+                                        time_t timeout,
+                                        unsigned char *der, unsigned int der_len)
 {
     struct context *ctx = context;
 
@@ -119,16 +120,16 @@
     if (!DC_CTX_add_session(ctx->dc, id, idlen, der, der_len,
                             (unsigned long)timeout * 1000)) {
         ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, "distributed scache 'add_session' failed");
-        return FALSE;
+        return APR_EGENERAL;
     }
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, "distributed scache 'add_session' successful");
-    return TRUE;
+    return APR_SUCCESS;
 }
 
-static BOOL ssl_scache_dc_retrieve(void *context,
-                                   server_rec *s, const UCHAR *id, int idlen,
-                                   unsigned char *dest, unsigned int *destlen,
-                                   apr_pool_t *p)
+static apr_status_t ssl_scache_dc_retrieve(void *context, server_rec *s, 
+                                           const unsigned char *id, unsigned int idlen,
+                                           unsigned char *dest, unsigned int *destlen,
+                                           apr_pool_t *p)
 {
     unsigned int data_len;
     struct context *ctx = context;
@@ -136,19 +137,20 @@
     /* Retrieve any corresponding session from the distributed cache context */
     if (!DC_CTX_get_session(ctx->dc, id, idlen, dest, *destlen, &data_len)) {
         ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, "distributed scache 'get_session' MISS");
-        return FALSE;
+        return APR_EGENERAL;
     }
     if (data_len > *destlen) {
         ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, "distributed scache 'get_session' OVERFLOW");
-        return FALSE;
+        return APR_ENOSPC;
     }
     *destlen = data_len;
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, "distributed scache 'get_session' HIT");
-    return TRUE;
+    return APR_SUCCESS;
 }
 
 static void ssl_scache_dc_remove(void *context, server_rec *s, 
-                                 UCHAR *id, int idlen, apr_pool_t *p)
+                                 const unsigned char *id, unsigned int idlen, 
+                                 apr_pool_t *p)
 {
     struct context *ctx = context;
 
@@ -160,7 +162,7 @@
     }
 }
 
-static void ssl_scache_dc_status(void *context, request_rec *r, int flags, apr_pool_t *pool)
+static void ssl_scache_dc_status(void *context, request_rec *r, int flags)
 {
     struct context *ctx = context;
 

Modified: httpd/httpd/trunk/modules/ssl/ssl_scache_memcache.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/ssl/ssl_scache_memcache.c?rev=633526&r1=633525&r2=633526&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/ssl/ssl_scache_memcache.c (original)
+++ httpd/httpd/trunk/modules/ssl/ssl_scache_memcache.c Tue Mar  4 08:14:10 2008
@@ -172,7 +172,7 @@
     /* noop. */
 }
 
-static char *mc_session_id2sz(const unsigned char *id, int idlen,
+static char *mc_session_id2sz(const unsigned char *id, unsigned int idlen,
                               char *str, int strsize)
 {
     char *cp;
@@ -190,10 +190,10 @@
     return str;
 }
 
-static BOOL ssl_scache_mc_store(void *context, server_rec *s, 
-                                UCHAR *id, int idlen,
-                                time_t timeout,
-                                unsigned char *ucaData, unsigned int nData)
+static apr_status_t ssl_scache_mc_store(void *context, server_rec *s, 
+                                        const unsigned char *id, unsigned int idlen,
+                                        time_t timeout,
+                                        unsigned char *ucaData, unsigned int nData)
 {
     struct context *ctx = context;
     char buf[MC_KEY_LEN];
@@ -203,7 +203,7 @@
     strkey = mc_session_id2sz(id, idlen, buf, sizeof(buf));
     if(!strkey) {
         ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, "scache_mc: Key generation borked.");
-        return FALSE;
+        return APR_EGENERAL;
     }
 
     rv = apr_memcache_set(ctx->mc, strkey, (char*)ucaData, nData, timeout, 0);
@@ -212,16 +212,16 @@
         ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s,
                      "scache_mc: error setting key '%s' "
                      "with %d bytes of data", strkey, nData);
-        return FALSE;
+        return rv;
     }
 
-    return TRUE;
+    return APR_SUCCESS;
 }
 
-static BOOL ssl_scache_mc_retrieve(void *context, server_rec *s, 
-                                   const UCHAR *id, int idlen,
-                                   unsigned char *dest, unsigned int *destlen,
-                                   apr_pool_t *p)
+static apr_status_t ssl_scache_mc_retrieve(void *context, server_rec *s, 
+                                           const unsigned char *id, unsigned int idlen,
+                                           unsigned char *dest, unsigned int *destlen,
+                                           apr_pool_t *p)
 {
     struct context *ctx = context;
     apr_size_t der_len;
@@ -234,7 +234,7 @@
     if (!strkey) {
         ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
                      "scache_mc: Key generation borked.");
-        return FALSE;
+        return APR_EGENERAL;
     }
 
     /* ### this could do with a subpool, but _getp looks like it will
@@ -247,21 +247,23 @@
             ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
                          "scache_mc: 'get_session' FAIL");
         }
-        return FALSE;
+        return rv;
     }
     else if (der_len > *destlen) {
         ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
                      "scache_mc: 'get_session' OVERFLOW");
-        return FALSE;
+        return rv;
     }    
 
     memcpy(dest, der, der_len);
     *destlen = der_len;
 
-    return TRUE;
+    return APR_SUCCESS;
 }
 
-static void ssl_scache_mc_remove(void *context, server_rec *s, UCHAR *id, int idlen, apr_pool_t
*p)
+static void ssl_scache_mc_remove(void *context, server_rec *s, 
+                                 const unsigned char *id, unsigned int idlen,
+                                 apr_pool_t *p)
 {
     struct context *ctx = context;
     char buf[MC_KEY_LEN];
@@ -284,8 +286,7 @@
     }
 }
 
-static void ssl_scache_mc_status(void *context, request_rec *r, 
-                                 int flags, apr_pool_t *pool)
+static void ssl_scache_mc_status(void *context, request_rec *r, int flags)
 {
     /* SSLModConfigRec *mc = myModConfig(r->server); */
     /* TODO: Make a mod_status handler. meh. */

Modified: httpd/httpd/trunk/modules/ssl/ssl_scache_shmcb.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/ssl/ssl_scache_shmcb.c?rev=633526&r1=633525&r2=633526&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/ssl/ssl_scache_shmcb.c (original)
+++ httpd/httpd/trunk/modules/ssl/ssl_scache_shmcb.c Tue Mar  4 08:14:10 2008
@@ -178,7 +178,7 @@
 
 /* A "normal-to-cyclic" memcpy. */
 static void shmcb_cyclic_ntoc_memcpy(unsigned int buf_size, unsigned char *data,
-                                     unsigned int dest_offset, unsigned char *src,
+                                     unsigned int dest_offset, const unsigned char *src,
                                      unsigned int src_len)
 {
     if (dest_offset + src_len < buf_size)
@@ -194,7 +194,7 @@
 
 /* A "cyclic-to-normal" memcpy. */
 static void shmcb_cyclic_cton_memcpy(unsigned int buf_size, unsigned char *dest,
-                                     unsigned char *data, unsigned int src_offset,
+                                     const unsigned char *data, unsigned int src_offset,
                                      unsigned int src_len)
 {
     if (src_offset + src_len < buf_size)
@@ -235,17 +235,19 @@
 
 /* Prototypes for low-level subcache operations */
 static void shmcb_subcache_expire(server_rec *, SHMCBHeader *, SHMCBSubcache *);
-static BOOL shmcb_subcache_store(server_rec *s, SHMCBHeader *header,
-                                 SHMCBSubcache *subcache, 
-                                 UCHAR *data, unsigned int data_len,
-                                 UCHAR *id, unsigned int id_len,
-                                 time_t expiry);
-static BOOL shmcb_subcache_retrieve(server_rec *, SHMCBHeader *, SHMCBSubcache *,
-                                    const UCHAR *id, unsigned int idlen,
-                                    UCHAR *data, unsigned int *datalen);
-                                    
-static BOOL shmcb_subcache_remove(server_rec *, SHMCBHeader *, SHMCBSubcache *,
-                                 UCHAR *, unsigned int);
+/* Returns zero on success, non-zero on failure. */   
+static int shmcb_subcache_store(server_rec *s, SHMCBHeader *header,
+                                SHMCBSubcache *subcache, 
+                                unsigned char *data, unsigned int data_len,
+                                const unsigned char *id, unsigned int id_len,
+                                time_t expiry);
+/* Returns zero on success, non-zero on failure. */   
+static int shmcb_subcache_retrieve(server_rec *, SHMCBHeader *, SHMCBSubcache *,
+                                   const unsigned char *id, unsigned int idlen,
+                                   unsigned char *data, unsigned int *datalen);
+/* Returns zero on success, non-zero on failure. */   
+static int shmcb_subcache_remove(server_rec *, SHMCBHeader *, SHMCBSubcache *,
+                                 const unsigned char *, unsigned int);
 
 /*
  * High-Level "handlers" as per ssl_scache.c
@@ -423,11 +425,11 @@
     }
 }
 
-static BOOL ssl_scache_shmcb_store(void *context, server_rec *s, 
-                                   UCHAR *id, int idlen,
-                                   time_t timeout, 
-                                   unsigned char *encoded,
-                                   unsigned int len_encoded)
+static apr_status_t ssl_scache_shmcb_store(void *context, server_rec *s, 
+                                           const unsigned char *id, unsigned int idlen,
+                                           time_t timeout, 
+                                           unsigned char *encoded,
+                                           unsigned int len_encoded)
 {
     struct context *ctx = context;
     SHMCBHeader *header = ctx->header;
@@ -439,50 +441,50 @@
     if (idlen < 4) {
         ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, "unusably short session_id provided "
                 "(%u bytes)", idlen);
-        return FALSE;
+        return APR_EINVAL;
     }
-    if (!shmcb_subcache_store(s, header, subcache, encoded,
-                              len_encoded, id, idlen, timeout)) {
+    if (shmcb_subcache_store(s, header, subcache, encoded,
+                             len_encoded, id, idlen, timeout)) {
         ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
                      "can't store a session!");
-        return FALSE;
+        return APR_ENOSPC;
     }
     header->stat_stores++;
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
                  "leaving ssl_scache_shmcb_store successfully");
-    return TRUE;
+    return APR_SUCCESS;
 }
 
-static BOOL ssl_scache_shmcb_retrieve(void *context, server_rec *s, 
-                                      const UCHAR *id, int idlen,
-                                      unsigned char *dest, unsigned int *destlen,
-                                      apr_pool_t *p)
+static apr_status_t ssl_scache_shmcb_retrieve(void *context, server_rec *s, 
+                                              const unsigned char *id, unsigned int idlen,
+                                              unsigned char *dest, unsigned int *destlen,
+                                              apr_pool_t *p)
 {
     struct context *ctx = context;
     SHMCBHeader *header = ctx->header;
     SHMCBSubcache *subcache = SHMCB_MASK(header, id);
-    BOOL rv;
+    int rv;
 
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
                  "ssl_scache_shmcb_retrieve (0x%02x -> subcache %d)",
                  SHMCB_MASK_DBG(header, id));
 
-    /* Get the session corresponding to the session_id or NULL if it doesn't
-     * exist (or is flagged as "removed"). */
+    /* Get the session corresponding to the session_id, if it exists. */
     rv = shmcb_subcache_retrieve(s, header, subcache, id, idlen,
                                  dest, destlen);
-    if (rv)
+    if (rv == 0)
         header->stat_retrieves_hit++;
     else
         header->stat_retrieves_miss++;
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
                  "leaving ssl_scache_shmcb_retrieve successfully");
 
-    return rv;
+    return rv == 0 ? APR_SUCCESS : APR_EGENERAL;
 }
 
 static void ssl_scache_shmcb_remove(void *context, server_rec *s, 
-                                    UCHAR *id, int idlen, apr_pool_t *p)
+                                    const unsigned char *id, unsigned int idlen,
+                                    apr_pool_t *p)
 {
     struct context *ctx = context;
     SHMCBHeader *header = ctx->header;
@@ -504,8 +506,7 @@
                  "leaving ssl_scache_shmcb_remove successfully");
 }
 
-static void ssl_scache_shmcb_status(void *context, request_rec *r, 
-                                    int flags, apr_pool_t *p)
+static void ssl_scache_shmcb_status(void *context, request_rec *r, int flags)
 {
     server_rec *s = r->server;
     struct context *ctx = context;
@@ -623,11 +624,11 @@
                  "we now have %u sessions", subcache->idx_used);
 }
 
-static BOOL shmcb_subcache_store(server_rec *s, SHMCBHeader *header,
-                                 SHMCBSubcache *subcache, 
-                                 UCHAR *data, unsigned int data_len,
-                                 UCHAR *id, unsigned int id_len,
-                                 time_t expiry)
+static int shmcb_subcache_store(server_rec *s, SHMCBHeader *header,
+                                SHMCBSubcache *subcache, 
+                                unsigned char *data, unsigned int data_len,
+                                const unsigned char *id, unsigned int id_len,
+                                time_t expiry)
 {
     unsigned int data_offset, new_idx, id_offset;
     SHMCBIndex *idx;
@@ -638,7 +639,7 @@
         ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
                      "inserting session larger (%d) than subcache data area (%d)",
                      total_len, header->subcache_data_size);
-        return FALSE;
+        return -1;
     }
 
     /* If there are entries to expire, ditch them first. */
@@ -724,13 +725,13 @@
                  "data_pos/data_used=%d/%d",
                  subcache->idx_pos, subcache->idx_used,
                  subcache->data_pos, subcache->data_used);
-    return TRUE;
+    return 0;
 }
 
-static BOOL shmcb_subcache_retrieve(server_rec *s, SHMCBHeader *header,
-                                    SHMCBSubcache *subcache, 
-                                    const UCHAR *id, unsigned int idlen,
-                                    UCHAR *dest, unsigned int *destlen)
+static int shmcb_subcache_retrieve(server_rec *s, SHMCBHeader *header,
+                                   SHMCBSubcache *subcache, 
+                                   const unsigned char *id, unsigned int idlen,
+                                   unsigned char *dest, unsigned int *destlen)
 {
     unsigned int pos;
     unsigned int loop = 0;
@@ -767,7 +768,7 @@
                                      dest, SHMCB_DATA(header, subcache),
                                      data_offset, *destlen);
 
-            return TRUE;
+            return 0;
         }
         /* Increment */
         loop++;
@@ -776,16 +777,16 @@
 
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
                  "shmcb_subcache_retrieve found no match");
-    return FALSE;
+    return -1;
+
 }
 
-static BOOL shmcb_subcache_remove(server_rec *s, SHMCBHeader *header,
-                                  SHMCBSubcache *subcache,
-                                  UCHAR *id, unsigned int idlen)
+static int shmcb_subcache_remove(server_rec *s, SHMCBHeader *header,
+                                 SHMCBSubcache *subcache,
+                                 const unsigned char *id, unsigned int idlen)
 {
     unsigned int pos;
     unsigned int loop = 0;
-    BOOL to_return = FALSE;
 
     /* Unlike the others, we don't do an expire-run first. This is to keep
      * consistent statistics where a "remove" operation may actually be the
@@ -794,7 +795,7 @@
      * intended session was in fact removed by an expiry run. */
 
     pos = subcache->idx_pos;
-    while (!to_return && (loop < subcache->idx_used)) {
+    while (loop < subcache->idx_used) {
         SHMCBIndex *idx = SHMCB_INDEX(subcache, pos);
 
         /* Only consider 'idx' if the id matches, and the "removed"
@@ -807,16 +808,16 @@
                          "possible match at idx=%d, data=%d", pos, idx->data_pos);
             /* Found the matching session, remove it quietly. */
             idx->removed = 1;
-            to_return = TRUE;
             ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
                              "shmcb_subcache_remove removing matching session");
+            return 0;
         }
         /* Increment */
         loop++;
         pos = SHMCB_CYCLIC_INCREMENT(pos, 1, header->index_num);
     }
 
-    return to_return;
+    return -1; /* failure */
 }
 
 const modssl_sesscache_provider modssl_sesscache_shmcb = {



Mime
View raw message