summaryrefslogtreecommitdiffstats
path: root/server/util_time.c
diff options
context:
space:
mode:
authorJim Jagielski <jim@apache.org>2014-06-03 18:02:44 +0200
committerJim Jagielski <jim@apache.org>2014-06-03 18:02:44 +0200
commitdb0457b3b27d776a00217908ae20411bcb9398b4 (patch)
treec677f447d0d1d7ccc5ce5dfd8032e47a84318d7b /server/util_time.c
parentfold in performance hack from eventopt (diff)
downloadapache2-db0457b3b27d776a00217908ae20411bcb9398b4.tar.xz
apache2-db0457b3b27d776a00217908ae20411bcb9398b4.zip
Break out common code to be share-able
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1599641 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'server/util_time.c')
-rw-r--r--server/util_time.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/server/util_time.c b/server/util_time.c
index 3632d0d583..4e8794d19a 100644
--- a/server/util_time.c
+++ b/server/util_time.c
@@ -15,6 +15,8 @@
*/
#include "util_time.h"
+#include "apr_env.h"
+
/* Number of characters needed to format the microsecond part of a timestamp.
@@ -304,3 +306,22 @@ AP_DECLARE(apr_status_t) ap_recent_rfc822_date(char *date_str, apr_time_t t)
*date_str++ = 0;
return APR_SUCCESS;
}
+
+AP_DECLARE(void) ap_force_set_tz(apr_pool_t *p) {
+ /* If the TZ variable is unset, many operationg systems,
+ * such as Linux, will at runtime read from /etc/localtime
+ * and call fstat on it.
+ *
+ * By forcing the time zone to UTC if it is unset, we gain
+ * about 2% in raw requests/second (since we format log files
+ * in the local time, if present)
+ *
+ * For more info, see:
+ * <http://www.gnu.org/s/hello/manual/libc/TZ-Variable.html>
+ */
+ char *v = NULL;
+
+ if (apr_env_get(&v, "TZ", p) != APR_SUCCESS) {
+ apr_env_set("TZ", "UTC+0", p);
+ }
+}