]> granicus.if.org Git - apache/commitdiff
My logger timestamp cache was using an apr_time_t as the cache key.
authorBrian Pane <brianp@apache.org>
Sun, 9 Jun 2002 04:48:41 +0000 (04:48 +0000)
committerBrian Pane <brianp@apache.org>
Sun, 9 Jun 2002 04:48:41 +0000 (04:48 +0000)
apr_time_t has a resolution of 1 microsecond.

For some reason, the cache hit rate wasn't very high.  :-)

With this change, the cache key is now the time in seconds, not usec.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@95588 13f79535-47bb-0310-9956-ffa450edef68

modules/loggers/mod_log_config.c

index 44111cdbf86debba53b65ce967b62e46404f0f40..202f672890d3ecdc5994dd3e5ef56f720a3e97c4 100644 (file)
@@ -457,9 +457,9 @@ static const char *log_request_time_custom(request_rec *r, char *a,
 
 #define DEFAULT_REQUEST_TIME_SIZE 32
 typedef struct {
-    apr_int64_t t;
+    unsigned t;
     char timestr[DEFAULT_REQUEST_TIME_SIZE];
-    apr_int64_t t_validate;
+    unsigned t_validate;
 } cached_request_time;
 
 #define TIME_CACHE_SIZE 4
@@ -507,11 +507,11 @@ static const char *log_request_time(request_rec *r, char *a)
 #else
         apr_time_t request_time = r->request_time;
 #endif
-        unsigned i = (unsigned)(request_time / APR_USEC_PER_SEC);
-        i &= TIME_CACHE_MASK;
+        unsigned t_seconds = (unsigned)(request_time / APR_USEC_PER_SEC);
+        unsigned i = t_seconds & TIME_CACHE_MASK;
         memcpy(cached_time, &(request_time_cache[i]), sizeof(*cached_time));
-        if ((request_time != cached_time->t) ||
-            (request_time != cached_time->t_validate)) {
+        if ((t_seconds != cached_time->t) ||
+            (t_seconds != cached_time->t_validate)) {
 
             /* Invalid or old snapshot, so compute the proper time string
              * and store it in the cache
@@ -528,13 +528,13 @@ static const char *log_request_time(request_rec *r, char *a)
             else {
                 sign = '+';
             }
-            cached_time->t = request_time;
+            cached_time->t = t_seconds;
             apr_snprintf(cached_time->timestr, DEFAULT_REQUEST_TIME_SIZE,
                          "[%02d/%s/%d:%02d:%02d:%02d %c%.2d%.2d]",
                          xt.tm_mday, apr_month_snames[xt.tm_mon],
                          xt.tm_year+1900, xt.tm_hour, xt.tm_min, xt.tm_sec,
                          sign, timz / (60*60), timz % (60*60));
-            cached_time->t_validate = request_time;
+            cached_time->t_validate = t_seconds;
             memcpy(&(request_time_cache[i]), cached_time,
                    sizeof(*cached_time));
         }