summaryrefslogtreecommitdiffstats
path: root/server/util_time.c
diff options
context:
space:
mode:
authorBrian Pane <brianp@apache.org>2002-03-17 06:13:12 +0100
committerBrian Pane <brianp@apache.org>2002-03-17 06:13:12 +0100
commite3bfcb14303575b6d57237ed6f2d45a7d86a1e8a (patch)
tree3be7519206a1ee348d9a52fc70af96307b4637d2 /server/util_time.c
parentfix a compile error (diff)
downloadapache2-e3bfcb14303575b6d57237ed6f2d45a7d86a1e8a.tar.xz
apache2-e3bfcb14303575b6d57237ed6f2d45a7d86a1e8a.zip
Use the "recent time" cache to optimize timestamp generation for
the httpd error log Background: According to some profile data that we collected on Solaris, half the run time of ap_log_rerror() was spent in localtime(3). With this change, the recent-time cache ensures that the error logger won't cause more than one localtime() call per second, no matter how high the error rate is. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@93977 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'server/util_time.c')
-rw-r--r--server/util_time.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/server/util_time.c b/server/util_time.c
index 1b2988d163..5b33e3ff4e 100644
--- a/server/util_time.c
+++ b/server/util_time.c
@@ -173,3 +173,48 @@ AP_DECLARE(apr_status_t) ap_explode_recent_gmt(apr_time_exp_t * tm,
{
return cached_explode(tm, t, exploded_cache_gmt, 1);
}
+
+AP_DECLARE(apr_status_t) ap_recent_ctime(char *date_str, apr_time_t t)
+{
+ /* ### This code is a clone of apr_ctime(), except that it
+ * uses ap_explode_recent_localtime() instead of apr_explode_localtime().
+ */
+ apr_time_exp_t xt;
+ const char *s;
+ int real_year;
+
+ /* example: "Wed Jun 30 21:49:08 1993" */
+ /* 123456789012345678901234 */
+
+ ap_explode_recent_localtime(&xt, t);
+ s = &apr_day_snames[xt.tm_wday][0];
+ *date_str++ = *s++;
+ *date_str++ = *s++;
+ *date_str++ = *s++;
+ *date_str++ = ' ';
+ s = &apr_month_snames[xt.tm_mon][0];
+ *date_str++ = *s++;
+ *date_str++ = *s++;
+ *date_str++ = *s++;
+ *date_str++ = ' ';
+ *date_str++ = xt.tm_mday / 10 + '0';
+ *date_str++ = xt.tm_mday % 10 + '0';
+ *date_str++ = ' ';
+ *date_str++ = xt.tm_hour / 10 + '0';
+ *date_str++ = xt.tm_hour % 10 + '0';
+ *date_str++ = ':';
+ *date_str++ = xt.tm_min / 10 + '0';
+ *date_str++ = xt.tm_min % 10 + '0';
+ *date_str++ = ':';
+ *date_str++ = xt.tm_sec / 10 + '0';
+ *date_str++ = xt.tm_sec % 10 + '0';
+ *date_str++ = ' ';
+ real_year = 1900 + xt.tm_year;
+ *date_str++ = real_year / 1000 + '0';
+ *date_str++ = real_year % 1000 / 100 + '0';
+ *date_str++ = real_year % 100 / 10 + '0';
+ *date_str++ = real_year % 10 + '0';
+ *date_str++ = 0;
+
+ return APR_SUCCESS;
+}