]> granicus.if.org Git - apache/commitdiff
Fold in a missing optimization...
authorJim Jagielski <jim@apache.org>
Fri, 16 Nov 2012 13:07:48 +0000 (13:07 +0000)
committerJim Jagielski <jim@apache.org>
Fri, 16 Nov 2012 13:07:48 +0000 (13:07 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1410328 13f79535-47bb-0310-9956-ffa450edef68

server/mpm/eventopt/eventopt.c

index a36414ad8f2cca33b36d62d96cf6c3e2bf03dd97..fbf189d5321ecef45b0ba1b988a943bdf391e8d7 100644 (file)
@@ -57,7 +57,7 @@
 #include "apr_atomic.h"
 #define APR_WANT_STRFUNC
 #include "apr_want.h"
-#include "apr_version.h"
+#include "apr_env.h"
 
 #if APR_HAVE_UNISTD_H
 #include <unistd.h>
 
 #define MPM_CHILD_PID(i) (ap_scoreboard_image->parent[i].pid)
 
-#if !APR_VERSION_AT_LEAST(1,4,0)
-#define apr_time_from_msec(x) (x * 1000)
-#endif
-
 #ifndef MAX_SECS_TO_LINGER
 #define MAX_SECS_TO_LINGER 30
 #endif
@@ -2145,6 +2141,27 @@ 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;
+    apr_status_t rv;
+
+    rv = apr_env_get(&v, "TZ", p);
+    if (v == NULL || rv == APR_ENOENT) {
+        apr_env_set("TZ", "UTC+0", p);
+    }
+}
+
 static void child_main(int child_num_arg)
 {
     apr_thread_t **threads;
@@ -3186,6 +3203,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