nginx-0.3.31-RELEASE import

    *) Change: now nginx passes the malformed proxied backend responses.

    *) Feature: the "listen" directives support the address in the "*:port"
       form.

    *) Feature: the EVFILER_TIMER support in MacOSX 10.4.

    *) Workaround: for MacOSX 64-bit kernel kqueue millisecond timeout
       bug.
       Thanks to Andrei Nigmatulin.

    *) Bugfix: if there were several "listen" directives listening one
       various addresses inside one server, then server names like
       "*.domain.tld" worked for first address only; the bug had appeared
       in 0.3.18.

    *) Bugfix: if the HTTPS protocol was used in the "proxy_pass" directive
       and the request body was in temporarily file then the request was
       not transferred.

    *) Bugfix: perl 5.8.8 compatibility.
diff --git a/auto/os/features b/auto/os/features
index 848e483..7028151 100644
--- a/auto/os/features
+++ b/auto/os/features
@@ -87,13 +87,88 @@
         ngx_feature_test="struct kevent  kev;
                           kev.fflags = NOTE_LOWAT;"
         . auto/feature
+
+
+        ngx_feature="kqueue's EVFILT_TIMER"
+        ngx_feature_name="NGX_HAVE_TIMER_EVENT"
+        ngx_feature_run=yes
+        ngx_feature_incs="#include <sys/event.h>
+#include <sys/time.h>"
+        ngx_feature_libs=
+        ngx_feature_test="int      kq;
+                  struct kevent    kev;
+                  struct timespec  ts;
+
+                  if ((kq = kqueue()) == -1) return 1;
+
+                  kev.ident = 0;
+                  kev.filter = EVFILT_TIMER;
+                  kev.flags = EV_ADD|EV_ENABLE;
+                  kev.fflags = 0;
+                  kev.data = 1000;
+                  kev.udata = 0;
+
+                  ts.tv_sec = 0;
+                  ts.tv_nsec = 0;
+
+                  if (kevent(kq, &kev, 1, &kev, 1, &ts) == -1) return 1;
+
+                  if (kev.flags & EV_ERROR) return 1;"
+
+        . auto/feature
+
+
+        if [ "$NGX_SYSTEM" = "Darwin" ]; then
+
+            ngx_feature="MacOSX 64-bit kqueue millisecond timeout bug"
+            ngx_feature_name=
+            ngx_feature_run=bug
+            ngx_feature_incs="#include <sys/event.h>
+#include <sys/time.h>"
+            ngx_feature_libs=
+            ngx_feature_test="int  kq;
+                  struct kevent    kev;
+                  struct timespec  ts;
+                  struct timeval   tv, tv0;
+
+                  kq = kqueue();
+
+                  ts.tv_sec = 0;
+                  ts.tv_nsec = 999000000;
+
+                  gettimeofday(&tv, 0);
+                  kevent(kq, NULL, 0, &kev, 1, &ts);
+                  gettimeofday(&tv0, 0);
+                  timersub(&tv0, &tv, &tv);
+
+                  if (tv.tv_sec * 1000000 + tv.tv_usec < 900000) return 1;"
+
+            . auto/feature
+
+            ngx_macosx_kevent_bug=$ngx_found
+        fi
     fi
 fi
 
-if [ "$NGX_SYSTEM" = "NetBSD" ]; then
 
-    have=NGX_HAVE_TIMER_EVENT . auto/have
-    echo " + kqueue's EVFILT_TIMER found"
+if [ ".$ngx_macosx_kevent_bug" = .yes ]; then
+
+    cat << END >> $NGX_AUTO_CONFIG_H
+
+#define NGX_MACOSX_KEVENT_BUG_SHIFT   << 32
+
+END
+
+else
+    cat << END >> $NGX_AUTO_CONFIG_H
+
+#define NGX_MACOSX_KEVENT_BUG_SHIFT
+
+END
+fi
+
+
+if [ "$NGX_SYSTEM" = "NetBSD" ]; then
 
     # NetBSD 2.0 incompatibly defines kevent.udata as "intptr_t"