httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jor...@apache.org
Subject svn commit: r726059 - in /httpd/httpd/trunk: include/ap_socache.h modules/cache/mod_socache_dbm.c modules/cache/mod_socache_dc.c modules/cache/mod_socache_memcache.c modules/cache/mod_socache_shmcb.c modules/ssl/ssl_scache.c
Date Fri, 12 Dec 2008 15:56:15 GMT
Author: jorton
Date: Fri Dec 12 07:56:15 2008
New Revision: 726059

URL: http://svn.apache.org/viewvc?rev=726059&view=rev
Log:
socache API tweaks based on chrisd's review:

* include/ap_socache.h (ap_socache_provider_t::store): Take a pool.
  (ap_socache_provider_t::retrieve): Guarantee APR_NOTFOUND for a
  "not found" result.
  (ap_socache_provider_t::remove): Return an apr_status_t.

* modules/cache/mod_socache_dc.c, modules/cache/mod_socache_dbm.c,
  modules/cache/mod_socache_shmcb,
  modules/cache/mod_socache_memcache.c: Adjust accordingly.

* modules/ssl/ssl_scache.c (ssl_scache_store): Pass pool to
  sesscache->store.

Modified:
    httpd/httpd/trunk/include/ap_socache.h
    httpd/httpd/trunk/modules/cache/mod_socache_dbm.c
    httpd/httpd/trunk/modules/cache/mod_socache_dc.c
    httpd/httpd/trunk/modules/cache/mod_socache_memcache.c
    httpd/httpd/trunk/modules/cache/mod_socache_shmcb.c
    httpd/httpd/trunk/modules/ssl/ssl_scache.c

Modified: httpd/httpd/trunk/include/ap_socache.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_socache.h?rev=726059&r1=726058&r2=726059&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_socache.h (original)
+++ httpd/httpd/trunk/include/ap_socache.h Fri Dec 12 07:56:15 2008
@@ -116,11 +116,14 @@
      * @param expiry Absolute time at which the object expires
      * @param data Data to store; binary blob
      * @param datalen Length of data blob
+     * @param pool Pool for temporary allocations.
+     * @return APR status value.
      */
     apr_status_t (*store)(ap_socache_instance_t *instance, server_rec *s, 
                           const unsigned char *id, unsigned int idlen, 
                           time_t expiry, 
-                          unsigned char *data, unsigned int datalen);
+                          unsigned char *data, unsigned int datalen,
+                          apr_pool_t *pool);
 
     /**
      * Retrieve a cached object.
@@ -132,6 +135,8 @@
      * @param datalen On entry, length of data buffer; on exit, the
      * number of bytes written to the data buffer.
      * @param pool Pool for temporary allocations.
+     * @return APR status value; APR_NOTFOUND if the object was not
+     * found
      */
     apr_status_t (*retrieve)(ap_socache_instance_t *instance, server_rec *s,
                              const unsigned char *id, unsigned int idlen,
@@ -145,9 +150,9 @@
      * @param idlen Length of id blob
      * @param pool Pool for temporary allocations.
      */
-    void (*remove)(ap_socache_instance_t *instance, server_rec *s,
-                   const unsigned char *id, unsigned int idlen,
-                   apr_pool_t *pool);
+    apr_status_t (*remove)(ap_socache_instance_t *instance, server_rec *s,
+                           const unsigned char *id, unsigned int idlen,
+                           apr_pool_t *pool);
 
     /** Dump the status of a cache instance for mod_status.  Will use
      * the ap_r* interfaces to produce appropriate status output.

Modified: httpd/httpd/trunk/modules/cache/mod_socache_dbm.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/mod_socache_dbm.c?rev=726059&r1=726058&r2=726059&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/mod_socache_dbm.c (original)
+++ httpd/httpd/trunk/modules/cache/mod_socache_dbm.c Fri Dec 12 07:56:15 2008
@@ -71,9 +71,9 @@
 
 static void socache_dbm_expire(ap_socache_instance_t *ctx, server_rec *s);
 
-static void socache_dbm_remove(ap_socache_instance_t *ctx, server_rec *s, 
-                               const unsigned char *id, unsigned int idlen,
-                               apr_pool_t *p);
+static apr_status_t socache_dbm_remove(ap_socache_instance_t *ctx, 
+                                       server_rec *s, const unsigned char *id, 
+                                       unsigned int idlen, apr_pool_t *p);
 
 static const char *socache_dbm_create(ap_socache_instance_t **context, 
                                       const char *arg, 
@@ -176,10 +176,11 @@
     return;
 }
 
-static apr_status_t socache_dbm_store(ap_socache_instance_t *ctx, server_rec *s,
-                                      const unsigned char *id, unsigned int idlen,
-                                      time_t expiry, unsigned char *ucaData, 
-                                      unsigned int nData)
+static apr_status_t socache_dbm_store(ap_socache_instance_t *ctx, 
+                                      server_rec *s, const unsigned char *id, 
+                                      unsigned int idlen, time_t expiry, 
+                                      unsigned char *ucaData, 
+                                      unsigned int nData, apr_pool_t *pool)
 {
     apr_dbm_t *dbm;
     apr_datum_t dbmkey;
@@ -315,9 +316,9 @@
     return APR_SUCCESS;
 }
 
-static void socache_dbm_remove(ap_socache_instance_t *ctx, server_rec *s, 
-                               const unsigned char *id, unsigned int idlen,
-                               apr_pool_t *p)
+static apr_status_t socache_dbm_remove(ap_socache_instance_t *ctx, 
+                                       server_rec *s, const unsigned char *id,
+                                       unsigned int idlen, apr_pool_t *p)
 {
     apr_dbm_t *dbm;
     apr_datum_t dbmkey;
@@ -336,12 +337,12 @@
                      "Cannot open SSLSessionCache DBM file `%s' for writing "
                      "(delete)",
                      ctx->data_file);
-        return;
+        return rv;
     }
     apr_dbm_delete(dbm, dbmkey);
     apr_dbm_close(dbm);
 
-    return;
+    return APR_SUCCESS;
 }
 
 static void socache_dbm_expire(ap_socache_instance_t *ctx, server_rec *s)

Modified: httpd/httpd/trunk/modules/cache/mod_socache_dc.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/mod_socache_dc.c?rev=726059&r1=726058&r2=726059&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/mod_socache_dc.c (original)
+++ httpd/httpd/trunk/modules/cache/mod_socache_dc.c Fri Dec 12 07:56:15 2008
@@ -93,7 +93,8 @@
 static apr_status_t socache_dc_store(ap_socache_instance_t *ctx, server_rec *s, 
                                      const unsigned char *id, unsigned int idlen,
                                      time_t timeout,
-                                     unsigned char *der, unsigned int der_len)
+                                     unsigned char *der, unsigned int der_len,
+                                     apr_pool_t *p)
 {
     /* !@#$%^ - why do we deal with *absolute* time anyway??? */
     timeout -= time(NULL);
@@ -128,15 +129,17 @@
     return APR_SUCCESS;
 }
 
-static void socache_dc_remove(ap_socache_instance_t *ctx, server_rec *s, 
-                              const unsigned char *id, unsigned int idlen, 
-                              apr_pool_t *p)
+static apr_status_t socache_dc_remove(ap_socache_instance_t *ctx, 
+                                      server_rec *s, const unsigned char *id, 
+                                      unsigned int idlen, apr_pool_t *p)
 {
     /* Remove any corresponding session from the distributed cache context */
     if (!DC_CTX_remove_session(ctx->dc, id, idlen)) {
         ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, "distributed scache 'remove_session' MISS");
+        return APR_NOTFOUND;
     } else {
         ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, "distributed scache 'remove_session' HIT");
+        return APR_SUCCESS;
     }
 }
 

Modified: httpd/httpd/trunk/modules/cache/mod_socache_memcache.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/mod_socache_memcache.c?rev=726059&r1=726058&r2=726059&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/mod_socache_memcache.c (original)
+++ httpd/httpd/trunk/modules/cache/mod_socache_memcache.c Fri Dec 12 07:56:15 2008
@@ -201,7 +201,8 @@
 static apr_status_t socache_mc_store(ap_socache_instance_t *ctx, server_rec *s, 
                                      const unsigned char *id, unsigned int idlen,
                                      time_t timeout,
-                                     unsigned char *ucaData, unsigned int nData)
+                                     unsigned char *ucaData, unsigned int nData,
+                                     apr_pool_t *p)
 {
     char buf[MC_KEY_LEN];
     apr_status_t rv;
@@ -222,8 +223,7 @@
     return APR_SUCCESS;
 }
 
-static apr_status_t socache_mc_retrieve(ap_socache_instance_t *ctx, 
-                                        server_rec *s, 
+static apr_status_t socache_mc_retrieve(ap_socache_instance_t *ctx, server_rec *s, 
                                         const unsigned char *id, unsigned int idlen,
                                         unsigned char *dest, unsigned int *destlen,
                                         apr_pool_t *p)
@@ -259,15 +259,15 @@
     return APR_SUCCESS;
 }
 
-static void socache_mc_remove(ap_socache_instance_t *ctx, server_rec *s, 
-                              const unsigned char *id, unsigned int idlen,
-                              apr_pool_t *p)
+static apr_status_t socache_mc_remove(ap_socache_instance_t *ctx, server_rec *s, 
+                                      const unsigned char *id, 
+                                      unsigned int idlen, apr_pool_t *p)
 {
     char buf[MC_KEY_LEN];
     apr_status_t rv;
 
     if (socache_mc_id2key(ctx, id, idlen, buf, sizeof buf)) {
-        return;
+        return APR_EINVAL;
     }
 
     rv = apr_memcache_delete(ctx->mc, buf, 0);
@@ -276,8 +276,9 @@
         ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, s,
                      "scache_mc: error deleting key '%s' ",
                      buf);
-        return;
     }
+
+    return rv;
 }
 
 static void socache_mc_status(ap_socache_instance_t *ctx, request_rec *r, int flags)

Modified: httpd/httpd/trunk/modules/cache/mod_socache_shmcb.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/mod_socache_shmcb.c?rev=726059&r1=726058&r2=726059&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/mod_socache_shmcb.c (original)
+++ httpd/httpd/trunk/modules/cache/mod_socache_shmcb.c Fri Dec 12 07:56:15 2008
@@ -447,11 +447,11 @@
 }
 
 static apr_status_t socache_shmcb_store(ap_socache_instance_t *ctx, 
-                                        server_rec *s, 
-                                        const unsigned char *id, unsigned int idlen,
-                                        time_t timeout, 
+                                        server_rec *s, const unsigned char *id, 
+                                        unsigned int idlen, time_t timeout, 
                                         unsigned char *encoded,
-                                        unsigned int len_encoded)
+                                        unsigned int len_encoded,
+                                        apr_pool_t *p)
 {
     SHMCBHeader *header = ctx->header;
     SHMCBSubcache *subcache = SHMCB_MASK(header, id);
@@ -503,12 +503,13 @@
     return rv == 0 ? APR_SUCCESS : APR_EGENERAL;
 }
 
-static void socache_shmcb_remove(ap_socache_instance_t *ctx, server_rec *s, 
-                                 const unsigned char *id, unsigned int idlen,
-                                 apr_pool_t *p)
+static apr_status_t socache_shmcb_remove(ap_socache_instance_t *ctx, 
+                                         server_rec *s, const unsigned char *id,
+                                         unsigned int idlen, apr_pool_t *p)
 {
     SHMCBHeader *header = ctx->header;
     SHMCBSubcache *subcache = SHMCB_MASK(header, id);
+    apr_status_t rv;
 
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
                  "socache_shmcb_remove (0x%02x -> subcache %d)",
@@ -516,14 +517,19 @@
     if (idlen < 4) {
         ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, "unusably short session_id provided "
                 "(%u bytes)", idlen);
-        return;
+        return APR_EINVAL;
     }
-    if (shmcb_subcache_remove(s, header, subcache, id, idlen))
+    if (shmcb_subcache_remove(s, header, subcache, id, idlen) == 0) {
         header->stat_removes_hit++;
-    else
+        rv = APR_SUCCESS;
+    } else {
         header->stat_removes_miss++;
+        rv = APR_NOTFOUND;
+    }
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
                  "leaving socache_shmcb_remove successfully");
+
+    return rv;
 }
 
 static void socache_shmcb_status(ap_socache_instance_t *ctx, 

Modified: httpd/httpd/trunk/modules/ssl/ssl_scache.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/ssl/ssl_scache.c?rev=726059&r1=726058&r2=726059&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/ssl/ssl_scache.c (original)
+++ httpd/httpd/trunk/modules/ssl/ssl_scache.c Fri Dec 12 07:56:15 2008
@@ -114,7 +114,7 @@
     }
     
     rv = mc->sesscache->store(mc->sesscache_context, s, id, idlen, 
-                              expiry, encoded, len);
+                              expiry, encoded, len, p);
 
     if (mc->sesscache->flags & AP_SOCACHE_FLAG_NOTMPSAFE) {
         ssl_mutex_off(s);



Mime
View raw message