]> granicus.if.org Git - apache/commitdiff
fold in performance hack from eventopt
authorJim Jagielski <jim@apache.org>
Tue, 3 Jun 2014 15:49:25 +0000 (15:49 +0000)
committerJim Jagielski <jim@apache.org>
Tue, 3 Jun 2014 15:49:25 +0000 (15:49 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1599625 13f79535-47bb-0310-9956-ffa450edef68

server/mpm/event/event.c

index 4d960e9d5cd8cdc94b3f4f4540924d9ae8014c1e..d307abecde2dc5075421d45d9a5fce7dac31bc1d 100644 (file)
@@ -57,6 +57,8 @@
 #include "apr_atomic.h"
 #define APR_WANT_STRFUNC
 #include "apr_want.h"
+#include "apr_env.h"
+
 #include "apr_version.h"
 
 #include <stdlib.h>
@@ -2418,6 +2420,25 @@ static void join_start_thread(apr_thread_t * start_thread_id)
     }
 }
 
+static void 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);
+    }
+}
+
 static void child_main(int child_num_arg)
 {
     apr_thread_t **threads;
@@ -3566,6 +3587,7 @@ static void event_hooks(apr_pool_t * p)
      */
     static const char *const aszSucc[] = { "core.c", NULL };
     one_process = 0;
+    force_set_tz(p);
 
     ap_hook_open_logs(event_open_logs, NULL, aszSucc, APR_HOOK_REALLY_FIRST);
     /* we need to set the MPM state before other pre-config hooks use MPM query