From: William A. Rowe Jr Date: Sat, 26 Jun 2010 00:26:01 +0000 (+0000) Subject: Introduce an socache iterator 'userctx' for the user to track the X-Git-Tag: 2.3.7~124 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5740b5cfd9c6c14497d712b30b1496bf8f8a323a;p=apache Introduce an socache iterator 'userctx' for the user to track the context of their own callback. Breaks API, but we probably wanted an mmn reset between .6 and .7 betas for unintentional/unnoticed ABI breaks. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@958157 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/include/ap_mmn.h b/include/ap_mmn.h index 89cca6cc10..8f0a0adc09 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -230,12 +230,13 @@ * 20100609.0 (2.3.6-dev) Dropped ap_args_to_table due to missing constraints. * 20100609.1 (2.3.7-dev) Introduce ap_log_cserror() * 20100609.2 (2.3.7-dev) Add deferred write pool to core_output_filter_ctx + * 20100625.0 (2.3.7-dev) Add 'userctx' to socache iterator callback prototype */ #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */ #ifndef MODULE_MAGIC_NUMBER_MAJOR -#define MODULE_MAGIC_NUMBER_MAJOR 20100609 +#define MODULE_MAGIC_NUMBER_MAJOR 20100625 #endif #define MODULE_MAGIC_NUMBER_MINOR 2 /* 0...n */ diff --git a/include/ap_socache.h b/include/ap_socache.h index ff90997149..e00c316f6d 100644 --- a/include/ap_socache.h +++ b/include/ap_socache.h @@ -61,25 +61,27 @@ struct ap_socache_hints { /** * Iterator callback prototype for the ap_socache_provider_t->iterate() method - * @param instance The cache instance (passed through) - * @param s Associated server structure (passed through) + * @param instance The cache instance + * @param s Associated server context (for logging) + * @param userctx User defined pointer passed from the iterator call * @param id Unique ID for the object (binary blob) * with a trailing null char for convenience * @param idlen Length of id blob * @param data Output buffer to place retrieved data (binary blob) * with a trailing null char for convenience * @param datalen Length of data buffer - * @param pool Pool for temporary allocations (passed through) + * @param pool Pool for temporary allocations * @return APR status value; return APR_SUCCESS or the iteration will halt; * this value is returned to the ap_socache_provider_t->iterate() caller */ -typedef apr_status_t (*ap_socache_iterator_t)(ap_socache_instance_t *instance, - server_rec *s, - const unsigned char *id, - unsigned int idlen, - const unsigned char *data, - unsigned int datalen, - apr_pool_t *pool); +typedef apr_status_t (ap_socache_iterator_t)(ap_socache_instance_t *instance, + server_rec *s, + void *userctx, + const unsigned char *id, + unsigned int idlen, + const unsigned char *data, + unsigned int datalen, + apr_pool_t *pool); /** A socache provider structure. socache providers are registered * with the ap_provider.h interface using the AP_SOCACHE_PROVIDER_* @@ -193,15 +195,16 @@ typedef struct ap_socache_provider_t { /** * Dump all cached objects through an iterator callback. * @param instance The cache instance - * @param s Associated server structure (for logging purposes) - * @param iterator The user provided callback which will receive + * @param s Associated server context (for processing and logging) + * @param userctx User defined pointer passed through to the iterator + * @param iterator The user provided callback function which will receive * individual calls for each unexpired id/data pair * @param pool Pool for temporary allocations. * @return APR status value; APR_NOTFOUND if the object was not * found */ apr_status_t (*iterate)(ap_socache_instance_t *instance, server_rec *s, - ap_socache_iterator_t *iterator, + void *userctx, ap_socache_iterator_t *iterator, apr_pool_t *pool); } ap_socache_provider_t; diff --git a/modules/cache/mod_socache_dbm.c b/modules/cache/mod_socache_dbm.c index 0fc3029880..728e1f1097 100644 --- a/modules/cache/mod_socache_dbm.c +++ b/modules/cache/mod_socache_dbm.c @@ -503,7 +503,7 @@ static void socache_dbm_status(ap_socache_instance_t *ctx, request_rec *r, } static apr_status_t socache_dbm_iterate(ap_socache_instance_t *ctx, - server_rec *s, + server_rec *s, void *userctx, ap_socache_iterator_t *iterator, apr_pool_t *pool) { @@ -539,7 +539,8 @@ static apr_status_t socache_dbm_iterate(ap_socache_instance_t *ctx, expired = TRUE; } if (!expired) { - rv = (*iterator)(ctx, s, (unsigned char *)dbmkey.dptr, dbmkey.dsize, + rv = (*iterator)(ctx, s, userctx, + (unsigned char *)dbmkey.dptr, dbmkey.dsize, (unsigned char *)dbmval.dptr + sizeof(apr_time_t), dbmval.dsize - sizeof(apr_time_t), pool); ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, s, diff --git a/modules/cache/mod_socache_dc.c b/modules/cache/mod_socache_dc.c index 674a6a7bcf..74b879cb22 100644 --- a/modules/cache/mod_socache_dc.c +++ b/modules/cache/mod_socache_dc.c @@ -155,7 +155,7 @@ static void socache_dc_status(ap_socache_instance_t *ctx, request_rec *r, int fl } static apr_status_t socache_dc_iterate(ap_socache_instance_t *instance, - server_rec *s, + server_rec *s, void *userctx, ap_socache_iterator_t *iterator, apr_pool_t *pool) { diff --git a/modules/cache/mod_socache_memcache.c b/modules/cache/mod_socache_memcache.c index 0d4858189c..9a3f26eeec 100644 --- a/modules/cache/mod_socache_memcache.c +++ b/modules/cache/mod_socache_memcache.c @@ -288,7 +288,7 @@ static void socache_mc_status(ap_socache_instance_t *ctx, request_rec *r, int fl } static apr_status_t socache_mc_iterate(ap_socache_instance_t *instance, - server_rec *s, + server_rec *s, void *userctx, ap_socache_iterator_t *iterator, apr_pool_t *pool) { diff --git a/modules/cache/mod_socache_shmcb.c b/modules/cache/mod_socache_shmcb.c index 952b810f19..bba1e9a477 100644 --- a/modules/cache/mod_socache_shmcb.c +++ b/modules/cache/mod_socache_shmcb.c @@ -259,6 +259,7 @@ static int shmcb_subcache_remove(server_rec *, SHMCBHeader *, SHMCBSubcache *, /* Returns result of the (iterator)() call, zero is success (continue) */ static apr_status_t shmcb_subcache_iterate(ap_socache_instance_t *instance, server_rec *s, + void *userctx, SHMCBHeader *header, SHMCBSubcache *subcache, ap_socache_iterator_t *iterator, @@ -634,7 +635,7 @@ static void socache_shmcb_status(ap_socache_instance_t *ctx, } static apr_status_t socache_shmcb_iterate(ap_socache_instance_t *instance, - server_rec *s, + server_rec *s, void *userctx, ap_socache_iterator_t *iterator, apr_pool_t *pool) { @@ -651,8 +652,8 @@ static apr_status_t socache_shmcb_iterate(ap_socache_instance_t *instance, /* Iterate over the subcaches */ for (loop = 0; loop < header->subcache_num && rv == APR_SUCCESS; loop++) { SHMCBSubcache *subcache = SHMCB_SUBCACHE(header, loop); - rv = shmcb_subcache_iterate(instance, s, header, subcache, iterator, - &buf, &buflen, pool, now); + rv = shmcb_subcache_iterate(instance, s, userctx, header, subcache, + iterator, &buf, &buflen, pool, now); } return rv; } @@ -911,6 +912,7 @@ static int shmcb_subcache_remove(server_rec *s, SHMCBHeader *header, static apr_status_t shmcb_subcache_iterate(ap_socache_instance_t *instance, server_rec *s, + void *userctx, SHMCBHeader *header, SHMCBSubcache *subcache, ap_socache_iterator_t *iterator, @@ -970,7 +972,7 @@ static apr_status_t shmcb_subcache_iterate(ap_socache_instance_t *instance, data_offset, dest_len); dest[dest_len] = '\0'; - rv = (*iterator)(instance, s, id, idx->id_len, + rv = (*iterator)(instance, s, userctx, id, idx->id_len, dest, dest_len, pool); ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, s, "shmcb entry iterated");