Re: [PATCH] mod_cache: Use provider API

2005-03-06 Thread Sander Striker
Justin Erenkrantz wrote:
--On Wednesday, August 4, 2004 12:39 PM -0700 Justin Erenkrantz 
[EMAIL PROTECTED] wrote:

This patch removes the mod_cache dependencies upon the odd vtable and 
hooks
and standardizes upon the ap_provider_* API.  mod_auth uses this provider
interface now as has mod_dav.
+1 (concept).
Sander


Re: [PATCH] mod_cache: Use provider API

2005-03-06 Thread Sander Striker
Sander Striker wrote:
Justin Erenkrantz wrote:
--On Wednesday, August 4, 2004 12:39 PM -0700 Justin Erenkrantz 
[EMAIL PROTECTED] wrote:

This patch removes the mod_cache dependencies upon the odd vtable and 
hooks
and standardizes upon the ap_provider_* API.  mod_auth uses this 
provider
interface now as has mod_dav.

+1 (concept).
Huh?! In that same thread justin had a nice comment:
 place bag over head
I'll go do that now.
FYI, this happens if you try and get your mail sorted out over two years
and you forget to sort it by date in your mailer...
Sander 'Doh' Striker


[PATCH] mod_cache: Use provider API

2004-08-04 Thread Justin Erenkrantz
This patch removes the mod_cache dependencies upon the odd vtable and hooks 
and standardizes upon the ap_provider_* API.  mod_auth uses this provider 
interface now as has mod_dav.

Besides removing a bunch of code, this has a number of beneficial side-effects:
- All operations related to a cache are in *one* location/structure (yay!)
- Removal of some cache wrappers that shouldn't have been there.
- The remaining cache wrappers don't have to lookup/parse the 'type' string 
every time.  Instead, it can just walk the pre-built provider list.
- If a cache handler is invoked, instead of doing strcmp's to ensure it was 
meant to be called, they can just invoke - skipping these checks.
- The ordering still remains the same (first cache to have it wins).

I do have some code commented out that needs to be deleted entirely, but you 
can get the idea of the patch from this one.

FWIW, the caching directive syntax remains the same.  It's just an internal 
reorganization.  -- justin


Re: [PATCH] mod_cache: Use provider API

2004-08-04 Thread Justin Erenkrantz
--On Wednesday, August 4, 2004 12:39 PM -0700 Justin Erenkrantz 
[EMAIL PROTECTED] wrote:

This patch removes the mod_cache dependencies upon the odd vtable and hooks
and standardizes upon the ap_provider_* API.  mod_auth uses this provider
interface now as has mod_dav.
place bag over head  -- justin
Index: modules/experimental/cache_storage.c
===
RCS file: /home/cvspublic/httpd-2.0/modules/experimental/cache_storage.c,v
retrieving revision 1.35
diff -u -r1.35 cache_storage.c
--- modules/experimental/cache_storage.c3 Aug 2004 08:20:21 -   1.35
+++ modules/experimental/cache_storage.c4 Aug 2004 05:01:08 -
@@ -17,12 +17,6 @@
#include mod_cache.h
-APR_HOOK_STRUCT(
-   APR_HOOK_LINK(remove_url)
-   APR_HOOK_LINK(create_entity)
-   APR_HOOK_LINK(open_entity)
-)
-
extern APR_OPTIONAL_FN_TYPE(ap_cache_generate_key) *cache_generate_key;
extern module AP_MODULE_DECLARE_DATA cache_module;
@@ -33,22 +27,25 @@
 * delete all URL entities from the cache
 *
 */
-int cache_remove_url(request_rec *r, const char *types, char *url)
+int cache_remove_url(request_rec *r, char *url)
{
-const char *next = types;
-const char *type;
+cache_provider_list *list;
apr_status_t rv;
char *key;
+cache_request_rec *cache = (cache_request_rec *)
+ ap_get_module_config(r-request_config, 
cache_module);

rv = cache_generate_key(r,r-pool,key);
if (rv != APR_SUCCESS) {
return rv;
}
+list = cache-providers;
+
/* for each specified cache type, delete the URL */
-while(next) {
-type = ap_cache_tokstr(r-pool, next, next);
-cache_run_remove_url(type, key);
+while(list) {
+list-provider-remove_url(key);
+list = list-next;
}
return OK;
}
@@ -65,11 +62,10 @@
 * decide whether or not it wants to cache this particular entity.
 * If the size is unknown, a size of -1 should be set.
 */
-int cache_create_entity(request_rec *r, const char *types, char *url, 
apr_off_t size)
+int cache_create_entity(request_rec *r, char *url, apr_off_t size)
{
+cache_provider_list *list;
cache_handle_t *h = apr_pcalloc(r-pool, sizeof(cache_handle_t));
-const char *next = types;
-const char *type;
char *key;
apr_status_t rv;
cache_request_rec *cache = (cache_request_rec *)
@@ -79,15 +75,19 @@
if (rv != APR_SUCCESS) {
return rv;
}
+
+list = cache-providers;
/* for each specified cache type, delete the URL */
-while (next) {
-type = ap_cache_tokstr(r-pool, next, next);
-switch (rv = cache_run_create_entity(h, r, type, key, size)) {
+while (list) {
+switch (rv = list-provider-create_entity(h, r, key, size)) {
case OK: {
cache-handle = h;
+cache-provider = list-provider;
+cache-provider_name = list-provider_name;
return OK;
}
case DECLINED: {
+list = list-next;
continue;
}
default: {
@@ -99,19 +99,6 @@
}

/*
- * remove a specific URL entity from the cache
- *
- * The specific entity referenced by the cache_handle is removed
- * from the cache, and the cache_handle is closed.
- */
-/* XXX Don't think we need to pass in request_rec or types ... */
-int cache_remove_entity(request_rec *r, const char *types, cache_handle_t *h)
-{
-h-remove_entity(h);
-return 1;
-}
-
-/*
 * select a specific URL entity in the cache
 *
 * It is possible to store more than one entity per URL. Content
@@ -122,10 +109,9 @@
 * This function returns OK if successful, DECLINED if no
 * cached entity fits the bill.
 */
-int cache_select_url(request_rec *r, const char *types, char *url)
+int cache_select_url(request_rec *r, char *url)
{
-const char *next = types;
-const char *type;
+cache_provider_list *list;
apr_status_t rv;
cache_handle_t *h;
char *key;
@@ -139,17 +125,20 @@
/* go through the cache types till we get a match */
h = cache-handle = apr_palloc(r-pool, sizeof(cache_handle_t));
-while (next) {
-type = ap_cache_tokstr(r-pool, next, next);
-switch ((rv = cache_run_open_entity(h, r, type, key))) {
+list = cache-providers;
+
+while (list) {
+switch ((rv = list-provider-open_entity(h, r, key))) {
case OK: {
char *vary = NULL;
const char *varyhdr = NULL;
-if (cache_recall_entity_headers(h, r) != APR_SUCCESS) {
+if (list-provider-recall_headers(h, r) != APR_SUCCESS) {
/* TODO: Handle this error */
return DECLINED;
}
+r-filename = apr_pstrdup(r-pool, h-cache_obj-info.filename);
+
/*
 * Check Content-Negotiation - Vary
 *
@@ -205,10 +194,13 @@
return DECLINED;
}
}
+cache-provider = list-provider;
+