httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From minf...@apache.org
Subject svn commit: r1000187 - in /httpd/httpd/trunk/modules/cache: cache_storage.c cache_util.h mod_cache.c mod_cache.h
Date Wed, 22 Sep 2010 20:28:11 GMT
Author: minfrin
Date: Wed Sep 22 20:28:11 2010
New Revision: 1000187

URL: http://svn.apache.org/viewvc?rev=1000187&view=rev
Log:
Make ap_cache_accept_headers, ap_cache_accept_headers, ap_cache_try_lock and
ap_cache_check_freshness private.

Added:
    httpd/httpd/trunk/modules/cache/cache_util.h
Modified:
    httpd/httpd/trunk/modules/cache/cache_storage.c
    httpd/httpd/trunk/modules/cache/mod_cache.c
    httpd/httpd/trunk/modules/cache/mod_cache.h

Modified: httpd/httpd/trunk/modules/cache/cache_storage.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/cache_storage.c?rev=1000187&r1=1000186&r2=1000187&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/cache_storage.c (original)
+++ httpd/httpd/trunk/modules/cache/cache_storage.c Wed Sep 22 20:28:11 2010
@@ -17,6 +17,7 @@
 #include "mod_cache.h"
 
 #include "cache_storage.h"
+#include "cache_util.h"
 
 APLOG_USE_MODULE(cache);
 
@@ -273,7 +274,7 @@ int cache_select(cache_request_rec *cach
             cache->provider_name = list->provider_name;
 
             /* Is our cached response fresh enough? */
-            fresh = ap_cache_check_freshness(h, cache, r);
+            fresh = cache_check_freshness(h, cache, r);
             if (!fresh) {
                 const char *etag, *lastmod;
 

Added: httpd/httpd/trunk/modules/cache/cache_util.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/cache_util.h?rev=1000187&view=auto
==============================================================================
--- httpd/httpd/trunk/modules/cache/cache_util.h (added)
+++ httpd/httpd/trunk/modules/cache/cache_util.h Wed Sep 22 20:28:11 2010
@@ -0,0 +1,106 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file cache_util.h
+ * @brief Cache Storage Functions
+ *
+ * @defgroup Cache_util  Cache Utility Functions
+ * @ingroup  MOD_CACHE
+ * @{
+ */
+
+#ifndef CACHE_UTIL_H
+#define CACHE_UTIL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "mod_cache.h"
+
+/**
+ * cache_util.c
+ */
+
+/**
+ * Check the freshness of the cache object per RFC2616 section 13.2 (Expiration Model)
+ * @param h cache_handle_t
+ * @param r request_rec
+ * @return 0 ==> cache object is stale, 1 ==> cache object is fresh
+ */
+int cache_check_freshness(cache_handle_t *h, cache_request_rec *cache,
+        request_rec *r);
+
+/**
+ * Try obtain a cache wide lock on the given cache key.
+ *
+ * If we return APR_SUCCESS, we obtained the lock, and we are clear to
+ * proceed to the backend. If we return APR_EEXISTS, the the lock is
+ * already locked, someone else has gone to refresh the backend data
+ * already, so we must return stale data with a warning in the mean
+ * time. If we return anything else, then something has gone pear
+ * shaped, and we allow the request through to the backend regardless.
+ *
+ * This lock is created from the request pool, meaning that should
+ * something go wrong and the lock isn't deleted on return of the
+ * request headers from the backend for whatever reason, at worst the
+ * lock will be cleaned up when the request is dies or finishes.
+ *
+ * If something goes truly bananas and the lock isn't deleted when the
+ * request dies, the lock will be trashed when its max-age is reached,
+ * or when a request arrives containing a Cache-Control: no-cache. At
+ * no point is it possible for this lock to permanently deny access to
+ * the backend.
+ */
+apr_status_t cache_try_lock(cache_server_conf *conf,
+        cache_request_rec *cache, request_rec *r, char *key);
+
+/**
+ * Remove the cache lock, if present.
+ *
+ * First, try to close the file handle, whose delete-on-close should
+ * kill the file. Otherwise, just delete the file by name.
+ *
+ * If no lock name has yet been calculated, do the calculation of the
+ * lock name first before trying to delete the file.
+ *
+ * If an optional bucket brigade is passed, the lock will only be
+ * removed if the bucket brigade contains an EOS bucket.
+ */
+apr_status_t cache_remove_lock(cache_server_conf *conf,
+        cache_request_rec *cache, request_rec *r, char *key,
+        apr_bucket_brigade *bb);
+
+/**
+ * Merge in cached headers into the response
+ * @param h cache_handle_t
+ * @param r request_rec
+ * @param preserve_orig If 1, the values in r->headers_out are preserved.
+ *        Otherwise, they are overwritten by the cached value.
+ */
+void cache_accept_headers(cache_handle_t *h, request_rec *r,
+        int preserve_orig);
+
+cache_provider_list *cache_get_providers(request_rec *r,
+        cache_server_conf *conf, apr_uri_t uri);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !CACHE_UTIL_H */
+/** @} */

Modified: httpd/httpd/trunk/modules/cache/mod_cache.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/mod_cache.c?rev=1000187&r1=1000186&r2=1000187&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/mod_cache.c (original)
+++ httpd/httpd/trunk/modules/cache/mod_cache.c Wed Sep 22 20:28:11 2010
@@ -17,6 +17,7 @@
 #include "mod_cache.h"
 
 #include "cache_storage.h"
+#include "cache_util.h"
 
 module AP_MODULE_DECLARE_DATA cache_module;
 APR_OPTIONAL_FN_TYPE(ap_cache_generate_key) *cache_generate_key;
@@ -89,7 +90,7 @@ static int cache_quick_handler(request_r
     /*
      * Which cache module (if any) should handle this request?
      */
-    if (!(providers = ap_cache_get_providers(r, conf, r->parsed_uri))) {
+    if (!(providers = cache_get_providers(r, conf, r->parsed_uri))) {
         return DECLINED;
     }
 
@@ -137,7 +138,7 @@ static int cache_quick_handler(request_r
                  * backend without any attempt to cache. this stops
                  * duplicated simultaneous attempts to cache an entity.
                  */
-                rv = ap_cache_try_lock(conf, cache, r, NULL);
+                rv = cache_try_lock(conf, cache, r, NULL);
                 if (APR_SUCCESS == rv) {
 
                     /*
@@ -346,7 +347,7 @@ static int cache_handler(request_rec *r)
     /*
      * Which cache module (if any) should handle this request?
      */
-    if (!(providers = ap_cache_get_providers(r, conf, r->parsed_uri))) {
+    if (!(providers = cache_get_providers(r, conf, r->parsed_uri))) {
         return DECLINED;
     }
 
@@ -379,7 +380,7 @@ static int cache_handler(request_rec *r)
              * backend without any attempt to cache. this stops
              * duplicated simultaneous attempts to cache an entity.
              */
-            rv = ap_cache_try_lock(conf, cache, r, NULL);
+            rv = cache_try_lock(conf, cache, r, NULL);
             if (APR_SUCCESS == rv) {
 
                 /*
@@ -590,7 +591,7 @@ static int cache_save_store(ap_filter_t 
             ap_remove_output_filter(f);
 
             /* give someone else the chance to cache the file */
-            ap_cache_remove_lock(conf, cache, f->r, cache->handle ?
+            cache_remove_lock(conf, cache, f->r, cache->handle ?
                     (char *)cache->handle->cache_obj->key : NULL, NULL);
 
             /* give up trying to cache, just step out the way */
@@ -611,7 +612,7 @@ static int cache_save_store(ap_filter_t 
         }
 
         /* conditionally remove the lock as soon as we see the eos bucket */
-        ap_cache_remove_lock(conf, cache, f->r, cache->handle ?
+        cache_remove_lock(conf, cache, f->r, cache->handle ?
                 (char *)cache->handle->cache_obj->key : NULL, cache->out);
 
         if (APR_BRIGADE_EMPTY(cache->out)) {
@@ -632,7 +633,7 @@ static int cache_save_store(ap_filter_t 
                 ap_remove_output_filter(f);
 
                 /* give someone else the chance to cache the file */
-                ap_cache_remove_lock(conf, cache, f->r, cache->handle ?
+                cache_remove_lock(conf, cache, f->r, cache->handle ?
                         (char *)cache->handle->cache_obj->key : NULL, NULL);
 
                 return ap_pass_brigade(f->next, in);
@@ -906,7 +907,7 @@ static int cache_save_filter(ap_filter_t
         ap_remove_output_filter(f);
 
         /* remove the lock file unconditionally */
-        ap_cache_remove_lock(conf, cache, r, cache->handle ?
+        cache_remove_lock(conf, cache, r, cache->handle ?
                 (char *)cache->handle->cache_obj->key : NULL, NULL);
 
         /* ship the data up the stack */
@@ -1010,7 +1011,7 @@ static int cache_save_filter(ap_filter_t
     if (rv != OK) {
         /* Caching layer declined the opportunity to cache the response */
         ap_remove_output_filter(f);
-        ap_cache_remove_lock(conf, cache, r, cache->handle ?
+        cache_remove_lock(conf, cache, r, cache->handle ?
                 (char *)cache->handle->cache_obj->key : NULL, NULL);
         return ap_pass_brigade(f->next, in);
     }
@@ -1141,7 +1142,7 @@ static int cache_save_filter(ap_filter_t
         r->headers_out = ap_cache_cacheable_headers_out(r);
 
         /* Merge in our cached headers.  However, keep any updated values. */
-        ap_cache_accept_headers(cache->handle, r, 1);
+        cache_accept_headers(cache->handle, r, 1);
     }
 
     /* Write away header information to cache. It is possible that we are
@@ -1213,7 +1214,7 @@ static int cache_save_filter(ap_filter_t
         }
 
         /* let someone else attempt to cache */
-        ap_cache_remove_lock(conf, cache, r, cache->handle ?
+        cache_remove_lock(conf, cache, r, cache->handle ?
                 (char *)cache->handle->cache_obj->key : NULL, NULL);
 
         return ap_pass_brigade(f->next, bb);
@@ -1224,7 +1225,7 @@ static int cache_save_filter(ap_filter_t
                      "cache: store_headers failed");
 
         ap_remove_output_filter(f);
-        ap_cache_remove_lock(conf, cache, r, cache->handle ?
+        cache_remove_lock(conf, cache, r, cache->handle ?
                 (char *)cache->handle->cache_obj->key : NULL, NULL);
         return ap_pass_brigade(f->next, in);
     }

Modified: httpd/httpd/trunk/modules/cache/mod_cache.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/mod_cache.h?rev=1000187&r1=1000186&r2=1000187&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/mod_cache.h (original)
+++ httpd/httpd/trunk/modules/cache/mod_cache.h Wed Sep 22 20:28:11 2010
@@ -276,15 +276,6 @@ CACHE_DECLARE(apr_time_t) ap_cache_curre
                                                apr_time_t now);
 
 /**
- * Check the freshness of the cache object per RFC2616 section 13.2 (Expiration Model)
- * @param h cache_handle_t
- * @param r request_rec
- * @return 0 ==> cache object is stale, 1 ==> cache object is fresh
- */
-CACHE_DECLARE(int) ap_cache_check_freshness(cache_handle_t *h, cache_request_rec *cache,
-                                            request_rec *r);
-
-/**
  * Check the whether the request allows a cached object to be served as per RFC2616
  * section 14.9.4 (Cache Revalidation and Reload Controls)
  * @param h cache_handle_t
@@ -293,62 +284,11 @@ CACHE_DECLARE(int) ap_cache_check_freshn
  */
 CACHE_DECLARE(int) ap_cache_check_allowed(request_rec *r);
 
-/**
- * Try obtain a cache wide lock on the given cache key.
- *
- * If we return APR_SUCCESS, we obtained the lock, and we are clear to
- * proceed to the backend. If we return APR_EEXISTS, the the lock is
- * already locked, someone else has gone to refresh the backend data
- * already, so we must return stale data with a warning in the mean
- * time. If we return anything else, then something has gone pear
- * shaped, and we allow the request through to the backend regardless.
- *
- * This lock is created from the request pool, meaning that should
- * something go wrong and the lock isn't deleted on return of the
- * request headers from the backend for whatever reason, at worst the
- * lock will be cleaned up when the request is dies or finishes.
- *
- * If something goes truly bananas and the lock isn't deleted when the
- * request dies, the lock will be trashed when its max-age is reached,
- * or when a request arrives containing a Cache-Control: no-cache. At
- * no point is it possible for this lock to permanently deny access to
- * the backend.
- */
-CACHE_DECLARE(apr_status_t) ap_cache_try_lock(cache_server_conf *conf,
-        cache_request_rec *cache, request_rec *r, char *key);
-
-/**
- * Remove the cache lock, if present.
- *
- * First, try to close the file handle, whose delete-on-close should
- * kill the file. Otherwise, just delete the file by name.
- *
- * If no lock name has yet been calculated, do the calculation of the
- * lock name first before trying to delete the file.
- *
- * If an optional bucket brigade is passed, the lock will only be
- * removed if the bucket brigade contains an EOS bucket.
- */
-CACHE_DECLARE(apr_status_t) ap_cache_remove_lock(cache_server_conf *conf,
-        cache_request_rec *cache, request_rec *r, char *key,
-        apr_bucket_brigade *bb);
-
-/**
- * Merge in cached headers into the response
- * @param h cache_handle_t
- * @param r request_rec
- * @param preserve_orig If 1, the values in r->headers_out are preserved.
- *        Otherwise, they are overwritten by the cached value.
- */
-CACHE_DECLARE(void) ap_cache_accept_headers(cache_handle_t *h, request_rec *r,
-                                            int preserve_orig);
-
 CACHE_DECLARE(apr_time_t) ap_cache_hex2usec(const char *x);
 CACHE_DECLARE(void) ap_cache_usec2hex(apr_time_t j, char *y);
 CACHE_DECLARE(char *) ap_cache_generate_name(apr_pool_t *p, int dirlevels,
                                              int dirlength,
                                              const char *name);
-CACHE_DECLARE(cache_provider_list *)ap_cache_get_providers(request_rec *r, cache_server_conf
*conf, apr_uri_t uri);
 CACHE_DECLARE(int) ap_cache_liststr(apr_pool_t *p, const char *list,
                                     const char *key, char **val);
 CACHE_DECLARE(const char *)ap_cache_tokstr(apr_pool_t *p, const char *list, const char **str);



Mime
View raw message