httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jor...@apache.org
Subject svn commit: r645924 - in /httpd/httpd/trunk/modules/cache: ap_socache.h mod_socache_dbm.c mod_socache_dc.c mod_socache_memcache.c mod_socache_shmcb.c
Date Tue, 08 Apr 2008 13:49:54 GMT
Author: jorton
Date: Tue Apr  8 06:49:52 2008
New Revision: 645924

URL: http://svn.apache.org/viewvc?rev=645924&view=rev
Log:
* modules/cache/ap_socache.h: Add ap_socache_instance_t object type.
  Adjust the provider interface to use this instance type throughout.

* modules/cache/mod_socache_dbm.c,
  modules/cache/mod_socache_memcache.c,
  modules/cache/mod_socache_shmcb.c,
  modules/cache/mod_socache_dc.c: Adjust all implementations to 
  define the instance object in place of the "struct context", and
  to take this object directly in the provider interface.

Modified:
    httpd/httpd/trunk/modules/cache/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

Modified: httpd/httpd/trunk/modules/cache/ap_socache.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/ap_socache.h?rev=645924&r1=645923&r2=645924&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/ap_socache.h (original)
+++ httpd/httpd/trunk/modules/cache/ap_socache.h Tue Apr  8 06:49:52 2008
@@ -36,6 +36,9 @@
  * serialize access to the provider. */
 #define AP_SOCACHE_FLAG_NOTMPSAFE (0x0001)
 
+/* A cache instance. */
+typedef struct ap_socache_instance_t ap_socache_instance_t;
+
 typedef struct ap_socache_provider_t {
     /* Canonical provider name: */
     const char *name;
@@ -51,17 +54,17 @@
      *
      * The context pointer returned in *INSTANCE will be passed as the
      * first argument to subsequent invocations. */
-    const char *(*create)(void **instance, const char *arg, 
+    const char *(*create)(ap_socache_instance_t **instance, const char *arg, 
                           apr_pool_t *tmp, apr_pool_t *p);
     /* Initialize the cache.  Return APR error code.   */
-    apr_status_t (*init)(void *instance, /* hints, namespace */
+    apr_status_t (*init)(ap_socache_instance_t *instance, /* hints, namespace */
                          server_rec *s, apr_pool_t *pool);
     /* Destroy a given cache context. */    
-    void (*destroy)(void *instance, server_rec *s);
+    void (*destroy)(ap_socache_instance_t *instance, server_rec *s);
     /* Store an object in the cache with key ID of length IDLEN, with
      * DATA of length DATALEN.  The object expires at abolute time
      * EXPIRY.  */
-    apr_status_t (*store)(void *instance, server_rec *s, 
+    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);
@@ -70,17 +73,17 @@
      * placed in DEST, which has length on entry of *DESTLEN.
      * *DESTLEN must be updated to equal the length of data written on
      * exit. */
-    apr_status_t (*retrieve)(void *instance, server_rec *s,
+    apr_status_t (*retrieve)(ap_socache_instance_t *instance, server_rec *s,
                              const unsigned char *id, unsigned int idlen,
                              unsigned char *data, unsigned int *datalen,
                              apr_pool_t *pool);
     /* Remove an object from the cache with key ID of length IDLEN.
      * POOL may be used for temporary allocations. */
-    void (*delete)(void *instance, server_rec *s,
+    void (*delete)(ap_socache_instance_t *instance, server_rec *s,
                    const unsigned char *id, unsigned int idlen,
                    apr_pool_t *pool);
     /* Dump cache status for mod_status output. */
-    void (*status)(void *instance, request_rec *r, int flags);
+    void (*status)(ap_socache_instance_t *instance, request_rec *r, int flags);
 } ap_socache_provider_t;
 
 /* Cache providers are registered using the ap_provider_* interface,

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=645924&r1=645923&r2=645924&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/mod_socache_dbm.c (original)
+++ httpd/httpd/trunk/modules/cache/mod_socache_dbm.c Tue Apr  8 06:49:52 2008
@@ -36,7 +36,7 @@
 
 /* Use of the context structure must be thread-safe after the initial
  * create/init; callers must hold the mutex. */
-struct context {
+struct ap_socache_instance_t {
     const char *data_file;
     /* Pool must only be used with the mutex held. */
     apr_pool_t *pool;
@@ -63,18 +63,17 @@
 #endif
 #endif
 
+static void socache_dbm_expire(ap_socache_instance_t *ctx, server_rec *s);
 
-
-static void socache_dbm_expire(struct context *ctx, server_rec *s);
-
-static void socache_dbm_remove(void *context, 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 const char *socache_dbm_create(void **context, const char *arg, 
+static const char *socache_dbm_create(ap_socache_instance_t **context, 
+                                      const char *arg, 
                                       apr_pool_t *tmp, apr_pool_t *p)
 {
-    struct context *ctx;
+    ap_socache_instance_t *ctx;
 
     *context = ctx = apr_pcalloc(p, sizeof *ctx);
 
@@ -88,9 +87,9 @@
     return NULL;
 }
 
-static apr_status_t socache_dbm_init(void *context, server_rec *s, apr_pool_t *p)
+static apr_status_t socache_dbm_init(ap_socache_instance_t *ctx, 
+                                     server_rec *s, apr_pool_t *p)
 {
-    struct context *ctx = context;
     apr_dbm_t *dbm;
     apr_status_t rv;
 
@@ -142,10 +141,8 @@
     return APR_SUCCESS;
 }
 
-static void socache_dbm_kill(void *context, server_rec *s)
+static void socache_dbm_kill(ap_socache_instance_t *ctx, server_rec *s)
 {
-    struct context *ctx = context;
-
     /* the correct way */
     unlink(apr_pstrcat(ctx->pool, ctx->data_file, SSL_DBM_FILE_SUFFIX_DIR, NULL));
     unlink(apr_pstrcat(ctx->pool, ctx->data_file, SSL_DBM_FILE_SUFFIX_PAG, NULL));
@@ -158,12 +155,11 @@
     return;
 }
 
-static apr_status_t socache_dbm_store(void *context, 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)
 {
-    struct context *ctx = context;
     apr_dbm_t *dbm;
     apr_datum_t dbmkey;
     apr_datum_t dbmval;
@@ -232,12 +228,12 @@
     return APR_SUCCESS;
 }
 
-static apr_status_t socache_dbm_retrieve(void *context, server_rec *s, 
-                                         const unsigned char *id, unsigned int idlen,
-                                         unsigned char *dest, unsigned int *destlen,
-                                         apr_pool_t *p)
+static apr_status_t socache_dbm_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)
 {
-    struct context *ctx = context;
     apr_dbm_t *dbm;
     apr_datum_t dbmkey;
     apr_datum_t dbmval;
@@ -299,11 +295,10 @@
     return APR_SUCCESS;
 }
 
-static void socache_dbm_remove(void *context, 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)
 {
-    struct context *ctx = context;
     apr_dbm_t *dbm;
     apr_datum_t dbmkey;
     apr_status_t rv;
@@ -329,7 +324,7 @@
     return;
 }
 
-static void socache_dbm_expire(struct context *ctx, server_rec *s)
+static void socache_dbm_expire(ap_socache_instance_t *ctx, server_rec *s)
 {
     apr_dbm_t *dbm;
     apr_datum_t dbmkey;
@@ -436,9 +431,9 @@
                  nElements, nElements-nDeleted, nDeleted);
 }
 
-static void socache_dbm_status(void *context, request_rec *r, int flags)
+static void socache_dbm_status(ap_socache_instance_t *ctx, request_rec *r, 
+                               int flags)
 {
-    struct context *ctx = context;
     apr_dbm_t *dbm;
     apr_datum_t dbmkey;
     apr_datum_t dbmval;

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=645924&r1=645923&r2=645924&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/mod_socache_dc.c (original)
+++ httpd/httpd/trunk/modules/cache/mod_socache_dc.c Tue Apr  8 06:49:52 2008
@@ -31,17 +31,18 @@
 #error "You must compile with a more recent version of the distcache-base package"
 #endif
 
-struct context {
+struct ap_socache_instance_t {
     /* Configured target server: */
     const char *target;
     /* distcache client context: */
     DC_CTX *dc;
 };
 
-static const char *socache_dc_create(void **context, const char *arg, 
+static const char *socache_dc_create(ap_socache_instance_t **context, 
+                                     const char *arg, 
                                      apr_pool_t *tmp, apr_pool_t *p)
 {
-    struct context *ctx;
+    struct ap_socache_instance_t *ctx;
 
     ctx = *context = apr_palloc(p, sizeof *ctx);
     
@@ -50,10 +51,8 @@
     return NULL;
 }
 
-static apr_status_t socache_dc_init(void *context, server_rec *s, apr_pool_t *p)
+static apr_status_t socache_dc_init(ap_socache_instance_t *ctx, server_rec *s, apr_pool_t
*p)
 {
-    struct context *ctx = ctx;
-
 #if 0
     /* If a "persistent connection" mode of operation is preferred, you *must*
      * also use the PIDCHECK flag to ensure fork()'d processes don't interlace
@@ -80,23 +79,19 @@
     return APR_SUCCESS;
 }
 
-static void socache_dc_kill(void *context, server_rec *s)
+static void socache_dc_kill(ap_socache_instance_t *ctx, server_rec *s)
 {
-    struct context *ctx = context;
-
     if (ctx && ctx->dc) {
         DC_CTX_free(ctx->dc);
         ctx->dc = NULL;
     }
 }
 
-static apr_status_t socache_dc_store(void *context, server_rec *s, 
+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)
 {
-    struct context *ctx = context;
-
     /* !@#$%^ - why do we deal with *absolute* time anyway??? */
     timeout -= time(NULL);
     /* Send the serialised session to the distributed cache context */
@@ -109,13 +104,12 @@
     return APR_SUCCESS;
 }
 
-static apr_status_t socache_dc_retrieve(void *context, server_rec *s, 
+static apr_status_t socache_dc_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)
 {
     unsigned int data_len;
-    struct context *ctx = context;
 
     /* Retrieve any corresponding session from the distributed cache context */
     if (!DC_CTX_get_session(ctx->dc, id, idlen, dest, *destlen, &data_len)) {
@@ -131,12 +125,10 @@
     return APR_SUCCESS;
 }
 
-static void socache_dc_remove(void *context, server_rec *s, 
+static void socache_dc_remove(ap_socache_instance_t *ctx, server_rec *s, 
                               const unsigned char *id, unsigned int idlen, 
                               apr_pool_t *p)
 {
-    struct context *ctx = context;
-
     /* 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");
@@ -145,10 +137,8 @@
     }
 }
 
-static void socache_dc_status(void *context, request_rec *r, int flags)
+static void socache_dc_status(ap_socache_instance_t *ctx, request_rec *r, int flags)
 {
-    struct context *ctx = context;
-
     ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
                   "distributed scache 'socache_dc_status'");
     ap_rprintf(r, "cache type: <b>DC (Distributed Cache)</b>, "

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=645924&r1=645923&r2=645924&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/mod_socache_memcache.c (original)
+++ httpd/httpd/trunk/modules/cache/mod_socache_memcache.c Tue Apr  8 06:49:52 2008
@@ -58,15 +58,16 @@
 #define MC_DEFAULT_SERVER_TTL 600
 #endif
 
-struct context {
+struct ap_socache_instance_t {
     const char *servers;
     apr_memcache_t *mc;
 };
 
-static const char *socache_mc_create(void **context, const char *arg, 
+static const char *socache_mc_create(ap_socache_instance_t **context, 
+                                     const char *arg, 
                                      apr_pool_t *tmp, apr_pool_t *p)
 {
-    struct context *ctx;
+    ap_socache_instance_t *ctx;
     
     *context = ctx = apr_palloc(p, sizeof *ctx);
 
@@ -75,7 +76,8 @@
     return NULL;
 }
 
-static apr_status_t socache_mc_init(void *context, server_rec *s, apr_pool_t *p)
+static apr_status_t socache_mc_init(ap_socache_instance_t *ctx, 
+                                    server_rec *s, apr_pool_t *p)
 {
     apr_status_t rv;
     int thread_limit = 0;
@@ -83,7 +85,6 @@
     char *cache_config;
     char *split;
     char *tok;
-    struct context *ctx = context;
 
     ap_mpm_query(AP_MPMQ_HARD_LIMIT_THREADS, &thread_limit);
 
@@ -158,7 +159,7 @@
     return APR_SUCCESS;
 }
 
-static void socache_mc_kill(void *context, server_rec *s)
+static void socache_mc_kill(ap_socache_instance_t *context, server_rec *s)
 {
     /* noop. */
 }
@@ -181,12 +182,11 @@
     return str;
 }
 
-static apr_status_t socache_mc_store(void *context, server_rec *s, 
+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)
 {
-    struct context *ctx = context;
     char buf[MC_KEY_LEN];
     char *strkey = NULL;
     apr_status_t rv;
@@ -209,12 +209,12 @@
     return APR_SUCCESS;
 }
 
-static apr_status_t socache_mc_retrieve(void *context, 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)
 {
-    struct context *ctx = context;
     apr_size_t der_len;
     char buf[MC_KEY_LEN], *der;
     char *strkey = NULL;
@@ -252,11 +252,10 @@
     return APR_SUCCESS;
 }
 
-static void socache_mc_remove(void *context, server_rec *s, 
+static void socache_mc_remove(ap_socache_instance_t *ctx, server_rec *s, 
                               const unsigned char *id, unsigned int idlen,
                               apr_pool_t *p)
 {
-    struct context *ctx = context;
     char buf[MC_KEY_LEN];
     char* strkey = NULL;
     apr_status_t rv;
@@ -277,7 +276,7 @@
     }
 }
 
-static void socache_mc_status(void *context, request_rec *r, int flags)
+static void socache_mc_status(ap_socache_instance_t *ctx, request_rec *r, int flags)
 {
     /* SSLModConfigRec *mc = myModConfig(r->server); */
     /* TODO: Make a mod_status handler. meh. */

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=645924&r1=645923&r2=645924&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/mod_socache_shmcb.c (original)
+++ httpd/httpd/trunk/modules/cache/mod_socache_shmcb.c Tue Apr  8 06:49:52 2008
@@ -91,7 +91,7 @@
     unsigned char removed;
 } SHMCBIndex;
 
-struct context {
+struct ap_socache_instance_t {
     const char *data_file;
     apr_size_t shm_size;
     apr_shm_t *shm;
@@ -259,10 +259,11 @@
  * subcache internals are deferred to shmcb_subcache_*** functions lower down
  */
 
-static const char *socache_shmcb_create(void **context, const char *arg, 
+static const char *socache_shmcb_create(ap_socache_instance_t **context,
+                                        const char *arg, 
                                         apr_pool_t *tmp, apr_pool_t *p)
 {
-    struct context *ctx;
+    ap_socache_instance_t *ctx;
     char *path, *cp, *cp2;
 
     /* Allocate the context. */
@@ -300,14 +301,14 @@
     return NULL;
 }
 
-static apr_status_t socache_shmcb_init(void *context, server_rec *s, apr_pool_t *p)
+static apr_status_t socache_shmcb_init(ap_socache_instance_t *ctx,
+                                       server_rec *s, apr_pool_t *p)
 {
     void *shm_segment;
     apr_size_t shm_segsize;
     apr_status_t rv;
     SHMCBHeader *header;
     unsigned int num_subcache, num_idx, loop;
-    struct context *ctx = context;
 
     /* Create shared memory segment */
     if (ctx->data_file == NULL) {
@@ -420,23 +421,21 @@
     return APR_SUCCESS;
 }
 
-static void socache_shmcb_kill(void *context, server_rec *s)
+static void socache_shmcb_kill(ap_socache_instance_t *ctx, server_rec *s)
 {
-    struct context *ctx = context;
-
     if (ctx && ctx->shm) {
         apr_shm_destroy(ctx->shm);
         ctx->shm = NULL;
     }
 }
 
-static apr_status_t socache_shmcb_store(void *context, server_rec *s, 
+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, 
                                         unsigned char *encoded,
                                         unsigned int len_encoded)
 {
-    struct context *ctx = context;
     SHMCBHeader *header = ctx->header;
     SHMCBSubcache *subcache = SHMCB_MASK(header, id);
 
@@ -460,12 +459,12 @@
     return APR_SUCCESS;
 }
 
-static apr_status_t socache_shmcb_retrieve(void *context, server_rec *s, 
-                                              const unsigned char *id, unsigned int idlen,
-                                              unsigned char *dest, unsigned int *destlen,
-                                              apr_pool_t *p)
+static apr_status_t socache_shmcb_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)
 {
-    struct context *ctx = context;
     SHMCBHeader *header = ctx->header;
     SHMCBSubcache *subcache = SHMCB_MASK(header, id);
     int rv;
@@ -487,11 +486,10 @@
     return rv == 0 ? APR_SUCCESS : APR_EGENERAL;
 }
 
-static void socache_shmcb_remove(void *context, server_rec *s, 
-                                    const unsigned char *id, unsigned int idlen,
-                                    apr_pool_t *p)
+static void socache_shmcb_remove(ap_socache_instance_t *ctx, server_rec *s, 
+                                 const unsigned char *id, unsigned int idlen,
+                                 apr_pool_t *p)
 {
-    struct context *ctx = context;
     SHMCBHeader *header = ctx->header;
     SHMCBSubcache *subcache = SHMCB_MASK(header, id);
 
@@ -511,10 +509,10 @@
                  "leaving socache_shmcb_remove successfully");
 }
 
-static void socache_shmcb_status(void *context, request_rec *r, int flags)
+static void socache_shmcb_status(ap_socache_instance_t *ctx, 
+                                 request_rec *r, int flags)
 {
     server_rec *s = r->server;
-    struct context *ctx = context;
     SHMCBHeader *header = ctx->header;
     unsigned int loop, total = 0, cache_total = 0, non_empty_subcaches = 0;
     time_t idx_expiry, min_expiry = 0, max_expiry = 0, average_expiry = 0;



Mime
View raw message