You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Bill Stoddard <bi...@wstoddard.com> on 2002/10/29 20:41:09 UTC

[PATCH] use r->request_now in lieu of calling apr_time_now()

Anyone see any problems with using r->request_time in liew of calling
apr_time_now() in age calculations? I am also not inclined to bump the MMN major
for this patch as the functions are all in experimental.

Bill

Index: modules/experimental/cache_util.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/experimental/cache_util.c,v
retrieving revision 1.20
diff -u -u -r1.20 cache_util.c
--- modules/experimental/cache_util.c	12 Oct 2002 07:51:09 -0000	1.20
+++ modules/experimental/cache_util.c	29 Oct 2002 18:21:54 -0000
@@ -138,7 +138,8 @@


 /* do a HTTP/1.1 age calculation */
-CACHE_DECLARE(apr_int64_t) ap_cache_current_age(cache_info *info, const
apr_time_t age_value)
+CACHE_DECLARE(apr_int64_t) ap_cache_current_age(cache_info *info, const
apr_time_t age_value,
+                                                apr_time_t now)
 {
     apr_time_t apparent_age, corrected_received_age, response_delay,
corrected_initial_age,
            resident_time, current_age;
@@ -149,7 +150,7 @@
     corrected_received_age = MAX(apparent_age, age_value);
     response_delay = info->response_time - info->request_time;
     corrected_initial_age = corrected_received_age + response_delay;
-    resident_time = apr_time_now() - info->response_time;
+    resident_time = now - info->response_time;
     current_age = corrected_initial_age + resident_time;

     return apr_time_sec(current_age);
@@ -206,7 +207,7 @@
     }

     /* calculate age of object */
-    age = ap_cache_current_age(info, age_c);
+    age = ap_cache_current_age(info, age_c, r->request_time);

     /* extract s-maxage */
     if (cc_cresp && ap_cache_liststr(r->pool, cc_cresp, "s-maxage", &val))
Index: modules/experimental/mod_cache.h
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/experimental/mod_cache.h,v
retrieving revision 1.34
diff -u -u -r1.34 mod_cache.h
--- modules/experimental/mod_cache.h	13 Oct 2002 19:35:04 -0000	1.34
+++ modules/experimental/mod_cache.h	29 Oct 2002 18:21:54 -0000
@@ -257,8 +257,9 @@

 /* cache_util.c */
 /* do a HTTP/1.1 age calculation */
-CACHE_DECLARE(apr_time_t) ap_cache_current_age(cache_info *info, const
apr_time_t age_value);
+CACHE_DECLARE(apr_time_t) ap_cache_current_age(cache_info *info, const
apr_time_t age_value,
+                                               apr_time_t current_time);

 /**
  * Check the freshness of the cache object per RFC2616 section 13.2 (Expiration
Model)


Re: [PATCH] use r->request_now in lieu of calling apr_time_now()

Posted by Brian Pane <br...@cnet.com>.
+1 on the change (and I agree that it shouldn't incur an
MMN change because it's in experimental).

Brian

On Tue, 2002-10-29 at 11:41, Bill Stoddard wrote:
> Anyone see any problems with using r->request_time in liew of calling
> apr_time_now() in age calculations? I am also not inclined to bump the MMN major
> for this patch as the functions are all in experimental.
> 
> Bill
> 
> Index: modules/experimental/cache_util.c
> ===================================================================
> RCS file: /home/cvs/httpd-2.0/modules/experimental/cache_util.c,v
> retrieving revision 1.20
> diff -u -u -r1.20 cache_util.c
> --- modules/experimental/cache_util.c	12 Oct 2002 07:51:09 -0000	1.20
> +++ modules/experimental/cache_util.c	29 Oct 2002 18:21:54 -0000
> @@ -138,7 +138,8 @@
> 
> 
>  /* do a HTTP/1.1 age calculation */
> -CACHE_DECLARE(apr_int64_t) ap_cache_current_age(cache_info *info, const
> apr_time_t age_value)
> +CACHE_DECLARE(apr_int64_t) ap_cache_current_age(cache_info *info, const
> apr_time_t age_value,
> +                                                apr_time_t now)
>  {
>      apr_time_t apparent_age, corrected_received_age, response_delay,
> corrected_initial_age,
>             resident_time, current_age;
> @@ -149,7 +150,7 @@
>      corrected_received_age = MAX(apparent_age, age_value);
>      response_delay = info->response_time - info->request_time;
>      corrected_initial_age = corrected_received_age + response_delay;
> -    resident_time = apr_time_now() - info->response_time;
> +    resident_time = now - info->response_time;
>      current_age = corrected_initial_age + resident_time;
> 
>      return apr_time_sec(current_age);
> @@ -206,7 +207,7 @@
>      }
> 
>      /* calculate age of object */
> -    age = ap_cache_current_age(info, age_c);
> +    age = ap_cache_current_age(info, age_c, r->request_time);
> 
>      /* extract s-maxage */
>      if (cc_cresp && ap_cache_liststr(r->pool, cc_cresp, "s-maxage", &val))
> Index: modules/experimental/mod_cache.h
> ===================================================================
> RCS file: /home/cvs/httpd-2.0/modules/experimental/mod_cache.h,v
> retrieving revision 1.34
> diff -u -u -r1.34 mod_cache.h
> --- modules/experimental/mod_cache.h	13 Oct 2002 19:35:04 -0000	1.34
> +++ modules/experimental/mod_cache.h	29 Oct 2002 18:21:54 -0000
> @@ -257,8 +257,9 @@
> 
>  /* cache_util.c */
>  /* do a HTTP/1.1 age calculation */
> -CACHE_DECLARE(apr_time_t) ap_cache_current_age(cache_info *info, const
> apr_time_t age_value);
> +CACHE_DECLARE(apr_time_t) ap_cache_current_age(cache_info *info, const
> apr_time_t age_value,
> +                                               apr_time_t current_time);
> 
>  /**
>   * Check the freshness of the cache object per RFC2616 section 13.2 (Expiration
> Model)