nginx-0.1.25-RELEASE import

    *) Bugfix: nginx did run on Linux parisc.

    *) Feature: nginx now does not start under FreeBSD if the sysctl
       kern.ipc.somaxconn value is too big.

    *) Bugfix: if a request was internally redirected by the
       ngx_http_index_module module to the ngx_http_proxy_module or
       ngx_http_fastcgi_module modules, then the index file was not closed
       after request completion.

    *) Feature: the "proxy_pass" can be used in location with regular
       expression.

    *) Feature: the ngx_http_rewrite_filter_module module supports the
       condition like "if ($HTTP_USER_AGENT ~ MSIE)".

    *) Bugfix: nginx started too slow if the large number of addresses and
       text values were used in the "geo" directive.

    *) Change: a variable name must be declared as "$name" in the "geo"
       directive. The previous variant without "$" is still supported, but
       will be removed soon.

    *) Feature: the "%{VARIABLE}v" logging parameter.

    *) Feature: the "set $name value" directive.

    *) Bugfix: gcc 4.0 compatibility.

    *) Feature: the --with-openssl-opt=OPTIONS autoconfiguration directive.
diff --git a/src/os/unix/ngx_aio_read_chain.c b/src/os/unix/ngx_aio_read_chain.c
index 31793d5..c6f9aea 100644
--- a/src/os/unix/ngx_aio_read_chain.c
+++ b/src/os/unix/ngx_aio_read_chain.c
@@ -16,7 +16,6 @@
     u_char       *buf, *prev;
     size_t        size;
     ssize_t       total;
-    ngx_err_t     err;
 
     if (c->read->pending_eof) {
         c->read->ready = 0;
diff --git a/src/os/unix/ngx_aio_write_chain.c b/src/os/unix/ngx_aio_write_chain.c
index 88b2474..b90f8bb 100644
--- a/src/os/unix/ngx_aio_write_chain.c
+++ b/src/os/unix/ngx_aio_write_chain.c
@@ -17,7 +17,6 @@
     off_t         send, sent;
     size_t        len;
     ssize_t       n, size;
-    ngx_err_t     err;
     ngx_chain_t  *cl;
 
     /* the maximum limit size is the maximum size_t value - the page size */
diff --git a/src/os/unix/ngx_alloc.c b/src/os/unix/ngx_alloc.c
index 258a10f..72cf4e4 100644
--- a/src/os/unix/ngx_alloc.c
+++ b/src/os/unix/ngx_alloc.c
@@ -11,11 +11,13 @@
 int ngx_pagesize;
 
 
-void *ngx_alloc(size_t size, ngx_log_t *log)
+void *
+ngx_alloc(size_t size, ngx_log_t *log)
 {
     void  *p;
 
-    if (!(p = malloc(size))) {
+    p = malloc(size);
+    if (p == NULL) {
         ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
                       "malloc() %uz bytes failed", size);
     }
@@ -26,7 +28,8 @@
 }
 
 
-void *ngx_calloc(size_t size, ngx_log_t *log)
+void *
+ngx_calloc(size_t size, ngx_log_t *log)
 {
     void  *p;
 
@@ -42,7 +45,8 @@
 
 #if (NGX_HAVE_POSIX_MEMALIGN)
 
-void *ngx_memalign(size_t alignment, size_t size, ngx_log_t *log)
+void *
+ngx_memalign(size_t alignment, size_t size, ngx_log_t *log)
 {
     void  *p;
 
@@ -60,11 +64,13 @@
 
 #elif (NGX_HAVE_MEMALIGN)
 
-void *ngx_memalign(size_t alignment, size_t size, ngx_log_t *log)
+void *
+ngx_memalign(size_t alignment, size_t size, ngx_log_t *log)
 {
     void  *p;
 
-    if (!(p = memalign(alignment, size))) {
+    p = memalign(alignment, size);
+    if (p == NULL) {
         ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
                       "memalign() %uz bytes aligned to %uz failed",
                       size, alignment);
diff --git a/src/os/unix/ngx_errno.c b/src/os/unix/ngx_errno.c
index 607b361..a3addf0 100644
--- a/src/os/unix/ngx_errno.c
+++ b/src/os/unix/ngx_errno.c
@@ -34,8 +34,7 @@
 
 u_char *ngx_strerror_r(int err, u_char *errstr, size_t size)
 {
-    char    *str;
-    size_t   len;
+    char  *str;
 
     if (size == 0) {
         return 0;
diff --git a/src/os/unix/ngx_errno.h b/src/os/unix/ngx_errno.h
index c1c5801..51d608b 100644
--- a/src/os/unix/ngx_errno.h
+++ b/src/os/unix/ngx_errno.h
@@ -25,7 +25,7 @@
 #define NGX_ENOTDIR       ENOTDIR
 #define NGX_EINVAL        EINVAL
 #define NGX_EPIPE         EPIPE
-#define NGX_EAGAIN        EWOULDBLOCK
+#define NGX_EAGAIN        EAGAIN
 #define NGX_EINPROGRESS   EINPROGRESS
 #define NGX_EADDRINUSE    EADDRINUSE
 #define NGX_ECONNABORTED  ECONNABORTED
@@ -52,10 +52,10 @@
 
 #else
 
-/* Solaris has threads-safe strerror() */
+/* Solaris has thread-safe strerror() */
 
 #define ngx_strerror_r(err, errstr, size)  \
-             ngx_cpystrn(errstr, (u_char *) strerror(err), size)
+    ngx_cpystrn(errstr, (u_char *) strerror(err), size)
 
 #endif
 
diff --git a/src/os/unix/ngx_files.c b/src/os/unix/ngx_files.c
index e67b2ca..f8f98c7 100644
--- a/src/os/unix/ngx_files.c
+++ b/src/os/unix/ngx_files.c
@@ -131,7 +131,6 @@
     u_char        *prev;
     size_t         size;
     ssize_t        n;
-    ngx_err_t      err;
     ngx_array_t    vec;
     struct iovec  *iov, iovs[NGX_IOVS];
 
@@ -162,7 +161,8 @@
                 iov->iov_len += cl->buf->last - cl->buf->pos;
 
             } else {
-                if (!(iov = ngx_array_push(&vec))) {
+                iov = ngx_array_push(&vec);
+                if (iov == NULL) {
                     return NGX_ERROR;
                 }
 
diff --git a/src/os/unix/ngx_freebsd_init.c b/src/os/unix/ngx_freebsd_init.c
index 044d9d5..7defb46 100644
--- a/src/os/unix/ngx_freebsd_init.c
+++ b/src/os/unix/ngx_freebsd_init.c
@@ -14,6 +14,7 @@
 int ngx_freebsd_kern_osreldate;
 int ngx_freebsd_hw_ncpu;
 int ngx_freebsd_net_inet_tcp_sendspace;
+int ngx_freebsd_kern_ipc_somaxconn;
 
 /* FreeBSD 4.9 */
 int ngx_freebsd_machdep_hlt_logical_cpus;
@@ -61,6 +62,10 @@
       &ngx_freebsd_net_inet_tcp_sendspace,
       sizeof(int), 0 },
 
+    { "kern.ipc.somaxconn",
+      &ngx_freebsd_kern_ipc_somaxconn,
+      sizeof(int), 0 },
+
     { "kern.ipc.zero_copy.send",
       &ngx_freebsd_kern_ipc_zero_copy_send,
       sizeof(int), 0 },
@@ -85,7 +90,7 @@
 
 ngx_int_t ngx_os_init(ngx_log_t *log)
 {
-    int         version;
+    int         version, somaxconn;
     size_t      size;
     ngx_err_t   err;
     ngx_uint_t  i;
@@ -203,6 +208,18 @@
         ngx_ncpu = ngx_freebsd_hw_ncpu;
     }
 
+    if (version < 600008) {
+        somaxconn = 32767;
+    } else {
+        somaxconn = 65535;
+    }
+
+    if (ngx_freebsd_kern_ipc_somaxconn > somaxconn) {
+        ngx_log_error(NGX_LOG_ALERT, log, 0,
+                      "sysctl kern.ipc.somaxconn must be no more than %d",
+                      somaxconn);
+        return NGX_ERROR;
+    }
 
     ngx_tcp_nodelay_and_tcp_nopush = 1;
 
diff --git a/src/os/unix/ngx_freebsd_rfork_thread.c b/src/os/unix/ngx_freebsd_rfork_thread.c
index 5dfd468..b7e803b 100644
--- a/src/os/unix/ngx_freebsd_rfork_thread.c
+++ b/src/os/unix/ngx_freebsd_rfork_thread.c
@@ -227,13 +227,15 @@
 
     /* create the thread errno' array */
 
-    if (!(errnos = ngx_calloc(n * sizeof(int), cycle->log))) {
+    errnos = ngx_calloc(n * sizeof(int), cycle->log);
+    if (errnos == NULL) {
         return NGX_ERROR;
     }
 
     /* create the thread tids array */
 
-    if (!(tids = ngx_calloc((n + 1) * sizeof(ngx_tid_t), cycle->log))) {
+    tids = ngx_calloc((n + 1) * sizeof(ngx_tid_t), cycle->log);
+    if (tids == NULL) {
         return NGX_ERROR;
     }
 
@@ -264,8 +266,7 @@
 
 ngx_tid_t ngx_thread_self()
 {
-    int        tid;
-    ngx_tid_t  pid;
+    ngx_int_t  tid;
 
     tid = ngx_gettid();
 
@@ -305,7 +306,8 @@
     ngx_mutex_t  *m;
     union semun   op;
 
-    if (!(m = ngx_alloc(sizeof(ngx_mutex_t), log))) {
+    m = ngx_alloc(sizeof(ngx_mutex_t), log);
+    if (m == NULL) {
         return NULL;
     }
 
@@ -353,7 +355,7 @@
 
 ngx_int_t ngx_mutex_dolock(ngx_mutex_t *m, ngx_int_t try)
 {
-    uint32_t       lock, new, old;
+    uint32_t       lock, old;
     ngx_uint_t     tries;
     struct sembuf  op;
 
@@ -483,7 +485,7 @@
 
 ngx_int_t ngx_mutex_unlock(ngx_mutex_t *m)
 {
-    uint32_t       lock, new, old;
+    uint32_t       lock, old;
     struct sembuf  op;
 
     if (!ngx_threaded) {
@@ -576,7 +578,8 @@
 {
     ngx_cond_t  *cv;
 
-    if (!(cv = ngx_alloc(sizeof(ngx_cond_t), log))) {
+    cv = ngx_alloc(sizeof(ngx_cond_t), log);
+    if (cv == NULL) {
         return NULL;
     }
 
diff --git a/src/os/unix/ngx_freebsd_rfork_thread.h b/src/os/unix/ngx_freebsd_rfork_thread.h
index 2af0adb..215d2dc 100644
--- a/src/os/unix/ngx_freebsd_rfork_thread.h
+++ b/src/os/unix/ngx_freebsd_rfork_thread.h
@@ -56,7 +56,7 @@
 extern size_t   ngx_thread_stack_size;
 
 
-static inline int ngx_gettid()
+static ngx_inline ngx_int_t ngx_gettid()
 {
     char  *sp;
 
diff --git a/src/os/unix/ngx_freebsd_sendfile_chain.c b/src/os/unix/ngx_freebsd_sendfile_chain.c
index 50cad30..a29aaf3 100644
--- a/src/os/unix/ngx_freebsd_sendfile_chain.c
+++ b/src/os/unix/ngx_freebsd_sendfile_chain.c
@@ -21,19 +21,19 @@
  * to postpone the sending - it not only sends a header and the first part of
  * the file in one packet, but also sends the file pages in the full packets.
  *
- * But until FreeBSD 4.5 the turning TCP_NOPUSH off does not flush a pending
- * data that less than MSS so that data may be sent with 5 second delay.
- * So we do not use TCP_NOPUSH on FreeBSD prior to 4.5 although it can be used
+ * But until FreeBSD 4.5 turning TCP_NOPUSH off does not flush a pending
+ * data that less than MSS, so that data may be sent with 5 second delay.
+ * So we do not use TCP_NOPUSH on FreeBSD prior to 4.5, although it can be used
  * for non-keepalive HTTP connections.
  */
 
 
 #define NGX_HEADERS   8
-#define NGX_TRAILERS  4
+#define NGX_TRAILERS  8
 
 
-ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
-                                        off_t limit)
+ngx_chain_t *
+ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
 {
     int              rc;
     u_char          *prev;
@@ -123,7 +123,8 @@
                 iov->iov_len += (size_t) size;
 
             } else {
-                if (!(iov = ngx_array_push(&header))) {
+                iov = ngx_array_push(&header);
+                if (iov == NULL) {
                     return NGX_CHAIN_ERROR;
                 }
 
@@ -197,7 +198,8 @@
                     iov->iov_len += (size_t) size;
 
                 } else {
-                    if (!(iov = ngx_array_push(&trailer))) {
+                    iov = ngx_array_push(&trailer);
+                    if (iov == NULL) {
                         return NGX_CHAIN_ERROR;
                     }
 
diff --git a/src/os/unix/ngx_linux_sendfile_chain.c b/src/os/unix/ngx_linux_sendfile_chain.c
index ac8c303..9ddac67 100644
--- a/src/os/unix/ngx_linux_sendfile_chain.c
+++ b/src/os/unix/ngx_linux_sendfile_chain.c
@@ -121,7 +121,8 @@
                 iov->iov_len += (size_t) size;
 
             } else {
-                if (!(iov = ngx_array_push(&header))) {
+                iov = ngx_array_push(&header);
+                if (iov == NULL) {
                     return NGX_CHAIN_ERROR;
                 }
 
diff --git a/src/os/unix/ngx_posix_init.c b/src/os/unix/ngx_posix_init.c
index 4fb5126..d48343b 100644
--- a/src/os/unix/ngx_posix_init.c
+++ b/src/os/unix/ngx_posix_init.c
@@ -182,7 +182,7 @@
 
         case ngx_signal_value(NGX_NOACCEPT_SIGNAL):
             ngx_noaccept = 1;
-            action = ", stop the accepting connections";
+            action = ", stop accepting connections";
             break;
 
         case ngx_signal_value(NGX_RECONFIGURE_SIGNAL):
diff --git a/src/os/unix/ngx_process.c b/src/os/unix/ngx_process.c
index 0825c5f..0562a46 100644
--- a/src/os/unix/ngx_process.c
+++ b/src/os/unix/ngx_process.c
@@ -214,7 +214,6 @@
     ngx_err_t        err;
     ngx_int_t        i;
     ngx_uint_t       one;
-    struct timeval   tv;
 
     one = 0;
 
diff --git a/src/os/unix/ngx_process_cycle.c b/src/os/unix/ngx_process_cycle.c
index a488809..9c5a7ee 100644
--- a/src/os/unix/ngx_process_cycle.c
+++ b/src/os/unix/ngx_process_cycle.c
@@ -11,7 +11,7 @@
 
 
 static void ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n,
-                                       ngx_int_t type);
+    ngx_int_t type);
 static void ngx_start_garbage_collector(ngx_cycle_t *cycle, ngx_int_t type);
 static void ngx_signal_worker_processes(ngx_cycle_t *cycle, int signo);
 static ngx_uint_t ngx_reap_childs(ngx_cycle_t *cycle);
@@ -23,7 +23,9 @@
 static void ngx_wakeup_worker_threads(ngx_cycle_t *cycle);
 static void *ngx_worker_thread_cycle(void *data);
 #endif
+#if 0
 static void ngx_garbage_collector_cycle(ngx_cycle_t *cycle, void *data);
+#endif
 
 
 ngx_uint_t    ngx_process;
@@ -59,7 +61,8 @@
 u_char  master_process[] = "master process";
 
 
-void ngx_master_process_cycle(ngx_cycle_t *cycle)
+void
+ngx_master_process_cycle(ngx_cycle_t *cycle)
 {
     char              *title;
     u_char            *p;
@@ -254,7 +257,8 @@
 }
 
 
-void ngx_single_process_cycle(ngx_cycle_t *cycle)
+void
+ngx_single_process_cycle(ngx_cycle_t *cycle)
 {
     ngx_uint_t  i;
 
@@ -300,8 +304,8 @@
 }
 
 
-static void ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n,
-                                       ngx_int_t type)
+static void
+ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n, ngx_int_t type)
 {
     ngx_int_t         i;
     ngx_channel_t     ch;
@@ -359,12 +363,12 @@
 }
 
 
-static void ngx_start_garbage_collector(ngx_cycle_t *cycle, ngx_int_t type)
+static void
+ngx_start_garbage_collector(ngx_cycle_t *cycle, ngx_int_t type)
 {
-    ngx_int_t         i;
-    ngx_channel_t     ch;
-
-    return;
+#if 0
+    ngx_int_t      i;
+    ngx_channel_t  ch;
 
     ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "start garbage collector");
 
@@ -397,16 +401,17 @@
         ngx_write_channel(ngx_processes[i].channel[0],
                           &ch, sizeof(ngx_channel_t), cycle->log);
     }
+#endif
 }
 
 
-static void ngx_signal_worker_processes(ngx_cycle_t *cycle, int signo)
+static void
+ngx_signal_worker_processes(ngx_cycle_t *cycle, int signo)
 {
     ngx_int_t      i;
     ngx_err_t      err;
     ngx_channel_t  ch;
 
-
     switch (signo) {
 
     case ngx_signal_value(NGX_SHUTDOWN_SIGNAL):
@@ -492,7 +497,8 @@
 }
 
 
-static ngx_uint_t ngx_reap_childs(ngx_cycle_t *cycle)
+static ngx_uint_t
+ngx_reap_childs(ngx_cycle_t *cycle)
 {
     ngx_int_t      i, n;
     ngx_uint_t     live;
@@ -619,7 +625,8 @@
 }
 
 
-static void ngx_master_exit(ngx_cycle_t *cycle)
+static void
+ngx_master_exit(ngx_cycle_t *cycle)
 {
     ngx_delete_pidfile(cycle);
 
@@ -631,11 +638,14 @@
 }
 
 
-static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
+static void
+ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
 {
+#if (NGX_THREADS)
     ngx_int_t          n;
     ngx_err_t          err;
     ngx_core_conf_t   *ccf;
+#endif
 
     ngx_worker_process_init(cycle, 1);
 
@@ -668,7 +678,9 @@
 
         for (n = 0; n < ngx_threads_n; n++) {
 
-            if (!(ngx_threads[n].cv = ngx_cond_init(cycle->log))) {
+            ngx_threads[n].cv = ngx_cond_init(cycle->log);
+
+            if (ngx_threads[n].cv == NULL) {
                 /* fatal */
                 exit(2);
             }
@@ -748,7 +760,8 @@
 }
 
 
-static void ngx_worker_process_init(ngx_cycle_t *cycle, ngx_uint_t priority)
+static void
+ngx_worker_process_init(ngx_cycle_t *cycle, ngx_uint_t priority)
 {
     sigset_t           set;
     ngx_int_t          n;
@@ -873,7 +886,8 @@
 }
 
 
-static void ngx_channel_handler(ngx_event_t *ev)
+static void
+ngx_channel_handler(ngx_event_t *ev)
 {
     ngx_int_t          n;
     ngx_channel_t      ch;
@@ -952,7 +966,8 @@
 
 #if (NGX_THREADS)
 
-static void ngx_wakeup_worker_threads(ngx_cycle_t *cycle)
+static void
+ngx_wakeup_worker_threads(ngx_cycle_t *cycle)
 {
     ngx_int_t   i;
     ngx_uint_t  live;
@@ -994,7 +1009,8 @@
 }
 
 
-static void *ngx_worker_thread_cycle(void *data)
+static void *
+ngx_worker_thread_cycle(void *data)
 {
     ngx_thread_t  *thr = data;
 
@@ -1022,7 +1038,8 @@
 
     ngx_setthrtitle("worker thread");
 
-    if (!(tls = ngx_calloc(sizeof(ngx_core_tls_t), cycle->log))) {
+    tls = ngx_calloc(sizeof(ngx_core_tls_t), cycle->log);
+    if (tls == NULL) {
         return (void *) 1;
     }
 
@@ -1077,7 +1094,10 @@
 #endif
 
 
-static void ngx_garbage_collector_cycle(ngx_cycle_t *cycle, void *data)
+#if 0
+
+static void
+ngx_garbage_collector_cycle(ngx_cycle_t *cycle, void *data)
 {
     ngx_uint_t         i;
     ngx_gc_t           ctx;
@@ -1123,3 +1143,5 @@
         ngx_process_events(cycle);
     }
 }
+
+#endif
diff --git a/src/os/unix/ngx_pthread_thread.c b/src/os/unix/ngx_pthread_thread.c
index 4903d5e..0b55c71 100644
--- a/src/os/unix/ngx_pthread_thread.c
+++ b/src/os/unix/ngx_pthread_thread.c
@@ -75,7 +75,8 @@
     int           err;
     ngx_mutex_t  *m;
 
-    if (!(m = ngx_alloc(sizeof(ngx_mutex_t), log))) {
+    m = ngx_alloc(sizeof(ngx_mutex_t), log);
+    if (m == NULL) {
         return NULL;
     }
     
@@ -189,7 +190,8 @@
     int          err;
     ngx_cond_t  *cv;
 
-    if (!(cv = ngx_alloc(sizeof(ngx_cond_t), log))) {
+    cv = ngx_alloc(sizeof(ngx_cond_t), log);
+    if (cv == NULL) {
         return NULL;
     }
     
diff --git a/src/os/unix/ngx_readv_chain.c b/src/os/unix/ngx_readv_chain.c
index 7c57b7a..47d8f3b 100644
--- a/src/os/unix/ngx_readv_chain.c
+++ b/src/os/unix/ngx_readv_chain.c
@@ -9,16 +9,20 @@
 #include <ngx_event.h>
 
 
+#define NGX_IOVS  16
+
+
 #if (NGX_HAVE_KQUEUE)
 
-ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
+ssize_t
+ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
 {
     u_char        *prev;
     ssize_t        n, size;
     ngx_err_t      err;
-    ngx_array_t    io;
+    ngx_array_t    vec;
     ngx_event_t   *rev;
-    struct iovec  *iov;
+    struct iovec  *iov, iovs[NGX_IOVS];
 
     rev = c->read; 
 
@@ -53,7 +57,11 @@
     iov = NULL;
     size = 0;
 
-    ngx_init_array(io, c->pool, 10, sizeof(struct iovec), NGX_ERROR);
+    vec.elts = iovs;
+    vec.nelts = 0;
+    vec.size = sizeof(struct iovec);
+    vec.nalloc = NGX_IOVS;
+    vec.pool = c->pool;
 
     /* coalesce the neighbouring bufs */
 
@@ -62,7 +70,11 @@
             iov->iov_len += chain->buf->end - chain->buf->last;
 
         } else {
-            ngx_test_null(iov, ngx_push_array(&io), NGX_ERROR);
+            iov = ngx_array_push(&vec);
+            if (iov == NULL) {
+                return NGX_ERROR;
+            }
+
             iov->iov_base = (void *) chain->buf->last;
             iov->iov_len = chain->buf->end - chain->buf->last;
         }
@@ -73,12 +85,12 @@
     }
 
     ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
-                   "readv: %d, last:%d", io.nelts, iov->iov_len);
+                   "readv: %d, last:%d", vec.nelts, iov->iov_len);
 
     rev = c->read;
 
     do {
-        n = readv(c->fd, (struct iovec *) io.elts, io.nelts);
+        n = readv(c->fd, (struct iovec *) vec.elts, vec.nelts);
 
         if (n >= 0) {
             if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
@@ -138,20 +150,25 @@
 
 #else /* ! NGX_HAVE_KQUEUE */
 
-ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
+ssize_t
+ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
 {
     u_char        *prev;
     ssize_t        n, size;
     ngx_err_t      err;
-    ngx_array_t    io;
+    ngx_array_t    vec;
     ngx_event_t   *rev;
-    struct iovec  *iov;
+    struct iovec  *iov, iovs[NGX_IOVS];
 
     prev = NULL;
     iov = NULL;
     size = 0;
 
-    ngx_init_array(io, c->pool, 10, sizeof(struct iovec), NGX_ERROR);
+    vec.elts = iovs;
+    vec.nelts = 0;
+    vec.size = sizeof(struct iovec);
+    vec.nalloc = NGX_IOVS;
+    vec.pool = c->pool;
 
     /* coalesce the neighbouring bufs */
 
@@ -160,7 +177,11 @@
             iov->iov_len += chain->buf->end - chain->buf->last;
 
         } else {
-            ngx_test_null(iov, ngx_push_array(&io), NGX_ERROR);
+            iov = ngx_array_push(&vec);
+            if (iov == NULL) {
+                return NGX_ERROR;
+            }
+
             iov->iov_base = chain->buf->last;
             iov->iov_len = chain->buf->end - chain->buf->last;
         }
@@ -171,12 +192,12 @@
     }
 
     ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
-                   "readv: %d:%d", io.nelts, iov->iov_len);
+                   "readv: %d:%d", vec.nelts, iov->iov_len);
 
     rev = c->read;
 
     do {
-        n = readv(c->fd, (struct iovec *) io.elts, io.nelts);
+        n = readv(c->fd, (struct iovec *) vec.elts, vec.nelts);
 
         if (n == 0) {
             rev->ready = 0;
diff --git a/src/os/unix/ngx_setproctitle.c b/src/os/unix/ngx_setproctitle.c
index 6c95cdf..25bbc9b 100644
--- a/src/os/unix/ngx_setproctitle.c
+++ b/src/os/unix/ngx_setproctitle.c
@@ -43,7 +43,8 @@
         size += ngx_strlen(environ[i]) + 1;
     }
 
-    if (!(p = ngx_alloc(size, log))) {
+    p = ngx_alloc(size, log);
+    if (p == NULL) {
         return NGX_ERROR;
     }
 
diff --git a/src/os/unix/ngx_socket.c b/src/os/unix/ngx_socket.c
index 523f1f4..1219589 100644
--- a/src/os/unix/ngx_socket.c
+++ b/src/os/unix/ngx_socket.c
@@ -22,7 +22,8 @@
 
 #if (NGX_HAVE_FIONBIO)
 
-int ngx_nonblocking(ngx_socket_t s)
+int
+ngx_nonblocking(ngx_socket_t s)
 {
     u_long  nb;
 
@@ -32,7 +33,8 @@
 }
 
 
-int ngx_blocking(ngx_socket_t s)
+int
+ngx_blocking(ngx_socket_t s)
 {
     u_long  nb;
 
@@ -46,7 +48,8 @@
 
 #if (NGX_FREEBSD)
 
-int ngx_tcp_nopush(ngx_socket_t s)
+int
+ngx_tcp_nopush(ngx_socket_t s)
 {
     int  tcp_nopush;
 
@@ -57,7 +60,8 @@
 }
 
 
-int ngx_tcp_push(ngx_socket_t s)
+int
+ngx_tcp_push(ngx_socket_t s)
 {
     int  tcp_nopush;
 
@@ -69,7 +73,8 @@
 
 #elif (NGX_LINUX)
 
-int ngx_tcp_nopush(ngx_socket_t s)
+int
+ngx_tcp_nopush(ngx_socket_t s)
 {
     int  cork;
 
@@ -79,7 +84,8 @@
                       (const void *) &cork, sizeof(int));
 }
 
-int ngx_tcp_push(ngx_socket_t s)
+int
+ngx_tcp_push(ngx_socket_t s)
 {
     int  cork;
 
@@ -91,14 +97,16 @@
 
 #else
 
-int ngx_tcp_nopush(ngx_socket_t s)
+int
+ngx_tcp_nopush(ngx_socket_t s)
 {
-    return NGX_OK;
+    return 0;
 }
 
-int ngx_tcp_push(ngx_socket_t s)
+int
+ngx_tcp_push(ngx_socket_t s)
 {
-    return NGX_OK;
+    return 0;
 }
 
 #endif
diff --git a/src/os/unix/ngx_solaris_sendfilev_chain.c b/src/os/unix/ngx_solaris_sendfilev_chain.c
index c5b8120..4345385 100644
--- a/src/os/unix/ngx_solaris_sendfilev_chain.c
+++ b/src/os/unix/ngx_solaris_sendfilev_chain.c
@@ -47,7 +47,7 @@
     sendfilevec_t  *sfv, sfvs[NGX_SENDFILEVECS];
     ngx_array_t     vec;
     ngx_event_t    *wev;
-    ngx_chain_t    *cl, *tail;
+    ngx_chain_t    *cl;
 
     wev = c->write;
 
@@ -107,7 +107,8 @@
                     sfv->sfv_len += (size_t) size;
 
                 } else {
-                    if (!(sfv = ngx_array_push(&vec))) {
+                    sfv = ngx_array_push(&vec);
+                    if (sfv == NULL) {
                         return NGX_CHAIN_ERROR;
                     }
 
@@ -140,7 +141,8 @@
                     sfv->sfv_len += (size_t) size;
 
                 } else {
-                    if (!(sfv = ngx_array_push(&vec))) {
+                    sfv = ngx_array_push(&vec);
+                    if (sfv == NULL) {
                         return NGX_CHAIN_ERROR;
                     }
 
diff --git a/src/os/unix/ngx_writev_chain.c b/src/os/unix/ngx_writev_chain.c
index 9cbcd86..ed3ad71 100644
--- a/src/os/unix/ngx_writev_chain.c
+++ b/src/os/unix/ngx_writev_chain.c
@@ -12,7 +12,8 @@
 #define NGX_IOVS  16
 
 
-ngx_chain_t *ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
+ngx_chain_t *
+ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
 {
     u_char        *prev;
     ssize_t        n, size, sent;
@@ -88,7 +89,8 @@
                 iov->iov_len += size;
 
             } else {
-                if (!(iov = ngx_array_push(&vec))) {
+                iov = ngx_array_push(&vec);
+                if (iov == NULL) {
                     return NGX_CHAIN_ERROR;
                 }
 
diff --git a/src/os/win32/ngx_alloc.c b/src/os/win32/ngx_alloc.c
index e73aa32..a3bca02 100644
--- a/src/os/win32/ngx_alloc.c
+++ b/src/os/win32/ngx_alloc.c
@@ -15,7 +15,8 @@
 {
     void  *p;
 
-    if (!(p = malloc(size))) {
+    p = malloc(size);
+    if (p == NULL) {
         ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
                       "malloc() %uz bytes failed", size);
     }
diff --git a/src/os/win32/ngx_files.c b/src/os/win32/ngx_files.c
index ce0fdc9..bea580b 100644
--- a/src/os/win32/ngx_files.c
+++ b/src/os/win32/ngx_files.c
@@ -179,7 +179,8 @@
     ngx_uint_t          collision;
     ngx_atomic_uint_t   num;
 
-    if (!(name = ngx_palloc(pool, to->len + 1 + 10 + 1 + sizeof("DELETE")))) {
+    name = ngx_palloc(pool, to->len + 1 + 10 + 1 + sizeof("DELETE"));
+    if (name == NULL) {
         return NGX_ERROR;
     }
 
@@ -301,6 +302,20 @@
 }
 
 
+ngx_int_t
+ngx_de_info(u_char *name, ngx_dir_t *dir)
+{
+    return NGX_OK;
+}
+
+
+ngx_int_t
+ngx_de_link_info(u_char *name, ngx_dir_t *dir)
+{
+    return NGX_OK;
+}
+
+
 ngx_int_t ngx_file_append_mode(ngx_fd_t fd)
 {
 #if 0
diff --git a/src/os/win32/ngx_files.h b/src/os/win32/ngx_files.h
index 48b54b3..a917431 100644
--- a/src/os/win32/ngx_files.h
+++ b/src/os/win32/ngx_files.h
@@ -132,10 +132,13 @@
 
 #define ngx_de_name(dir)            ((u_char *) (dir)->fd.cFileName)
 #define ngx_de_namelen(dir)         ngx_strlen((dir)->fd.cFileName)
-#define ngx_de_info(name, dir)      NGX_OK
+
+ngx_int_t ngx_de_info(u_char *name, ngx_dir_t *dir);
 #define ngx_de_info_n               "dummy()"
-#define ngx_de_link_info(name, dir) NGX_OK
+
+ngx_int_t ngx_de_link_info(u_char *name, ngx_dir_t *dir);
 #define ngx_de_link_info_n          "dummy()"
+
 #define ngx_de_is_dir(dir)                                                    \
     ((dir)->fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
 #define ngx_de_is_file(dir)                                                   \
diff --git a/src/os/win32/ngx_process_cycle.c b/src/os/win32/ngx_process_cycle.c
index e0635a5..2251ff2 100644
--- a/src/os/win32/ngx_process_cycle.c
+++ b/src/os/win32/ngx_process_cycle.c
@@ -206,7 +206,7 @@
 
     cycle = (ngx_cycle_t *) ngx_cycle;
 
-    for ( ;; ) {
+    while (!ngx_quit) {
         ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "worker cycle");
 
         ngx_process_events(cycle);
diff --git a/src/os/win32/ngx_socket.c b/src/os/win32/ngx_socket.c
index fc77433..7590c33 100644
--- a/src/os/win32/ngx_socket.c
+++ b/src/os/win32/ngx_socket.c
@@ -8,7 +8,8 @@
 #include <ngx_core.h>
 
 
-int ngx_nonblocking(ngx_socket_t s)
+int
+ngx_nonblocking(ngx_socket_t s)
 {
     unsigned long  nb = 1;
 
@@ -16,9 +17,17 @@
 }
 
 
-int ngx_blocking(ngx_socket_t s)
+int
+ngx_blocking(ngx_socket_t s)
 {
     unsigned long  nb = 0;
 
     return ioctlsocket(s, FIONBIO, &nb);
 }
+
+
+int
+ngx_tcp_push(ngx_socket_t s)
+{
+    return 0;
+}
diff --git a/src/os/win32/ngx_socket.h b/src/os/win32/ngx_socket.h
index 8875288..95ecbe8 100644
--- a/src/os/win32/ngx_socket.h
+++ b/src/os/win32/ngx_socket.h
@@ -98,10 +98,7 @@
 extern LPFN_TRANSMITFILE          transmitfile;
 
 
-static ngx_inline int ngx_tcp_push(ngx_socket_t s) {
-     return 0;
-}
-
+int ngx_tcp_push(ngx_socket_t s);
 #define ngx_tcp_push_n        "tcp_push()"
 
 
diff --git a/src/os/win32/ngx_thread.c b/src/os/win32/ngx_thread.c
index 8fae0e3..0703ac7 100644
--- a/src/os/win32/ngx_thread.c
+++ b/src/os/win32/ngx_thread.c
@@ -66,3 +66,19 @@
 {
     return (ngx_mutex_t *) 1;
 }
+
+
+/* STUB */
+
+ngx_int_t
+ngx_mutex_lock(ngx_mutex_t *m) {
+    return NGX_OK;
+}
+
+
+ngx_int_t
+ngx_mutex_trylock(ngx_mutex_t *m) {
+    return NGX_OK;
+}
+
+/**/
diff --git a/src/os/win32/ngx_thread.h b/src/os/win32/ngx_thread.h
index 5b3c4da..b55dcca 100644
--- a/src/os/win32/ngx_thread.h
+++ b/src/os/win32/ngx_thread.h
@@ -22,8 +22,8 @@
 } ngx_mutex_t;
 
 
-ngx_err_t ngx_create_thread(ngx_tid_t *tid, void* (*func)(void *arg), void *arg,
-                            ngx_log_t *log);
+ngx_err_t ngx_create_thread(ngx_tid_t *tid, void* (*func)(void *arg),
+    void *arg, ngx_log_t *log);
 ngx_int_t ngx_init_threads(int n, size_t size, ngx_cycle_t *cycle);
 
 ngx_err_t ngx_thread_key_create(ngx_tls_key_t *key);
@@ -41,14 +41,15 @@
 
 ngx_mutex_t *ngx_mutex_init(ngx_log_t *log, ngx_uint_t flags);
 
+ngx_int_t ngx_mutex_lock(ngx_mutex_t *m);
+ngx_int_t ngx_mutex_trylock(ngx_mutex_t *m);
+
 
 /* STUB */
 #define NGX_MUTEX_LIGHT             0
 
-#define ngx_mutex_lock(m)           NGX_OK
-#define ngx_mutex_trylock(m)        NGX_OK
 #define ngx_mutex_unlock(m)
-/* */
+/**/
 
 
 extern ngx_int_t  ngx_threads_n;
diff --git a/src/os/win32/ngx_win32_config.h b/src/os/win32/ngx_win32_config.h
index 36af239..02d4db5 100644
--- a/src/os/win32/ngx_win32_config.h
+++ b/src/os/win32/ngx_win32_config.h
@@ -37,7 +37,6 @@
 
 #pragma warning(default:4201)
 
-
 /* disable some "-W4" level warnings */
 
 /* 'type cast': from function pointer to data pointer */
@@ -49,14 +48,13 @@
 /* unreferenced formal parameter */
 #pragma warning(disable:4100)
 
-/* conditional expression is constant */
+/* FD_SET() and FD_CLR(): conditional expression is constant */
 #pragma warning(disable:4127)
 
-/* unreachable code */
-#pragma warning(disable:4702)
-
+#if 0
 /* assignment within conditional expression */
 #pragma warning(disable:4706)
+#endif
 
 /* function 'ngx_handle_write_event' not inlined */
 #pragma warning(disable:4710)
@@ -66,9 +64,6 @@
 
 #ifdef __WATCOMC__
 
-/* unreachable code */
-#pragma disable_message(201)
-
 /* symbol 'ngx_rbtree_min' has been defined, but not referenced */
 #pragma disable_message(202)
 
@@ -80,25 +75,16 @@
 /* the end of the precompiled headers */
 #pragma hdrstop
 
-/*
- * 'fd' is assigned a value that is never used in function ngx_event_init_conf
- */
-#pragma warn -8004
-
-/* condition is always false */
-#pragma warn -8008
-
 /* functions containing (for|while|some if) are not expanded inline */
 #pragma warn -8027
 
 /* unreferenced formal parameter */
 #pragma warn -8057
 
+#if 0
 /* assignment within conditional expression */
 #pragma warn -8060
-
-/* unreachable code */
-#pragma warn -8066
+#endif
 
 #endif
 
diff --git a/src/os/win32/ngx_wsarecv_chain.c b/src/os/win32/ngx_wsarecv_chain.c
index 2e2f7cc..c22a08d 100644
--- a/src/os/win32/ngx_wsarecv_chain.c
+++ b/src/os/win32/ngx_wsarecv_chain.c
@@ -9,16 +9,21 @@
 #include <ngx_event.h>
 
 
-ssize_t ngx_wsarecv_chain(ngx_connection_t *c, ngx_chain_t *chain)
+#define NGX_WSABUFS  8 
+
+
+ssize_t
+ngx_wsarecv_chain(ngx_connection_t *c, ngx_chain_t *chain)
 {
     int           rc;
     u_char       *prev;
     u_long        bytes, flags;
     size_t        size;
-    WSABUF       *wsabuf;
     ngx_err_t     err;
-    ngx_array_t   io;
+    ngx_array_t   vec;
     ngx_event_t  *rev;
+    LPWSABUF      wsabuf;
+    WSABUF        wsabufs[NGX_WSABUFS];
 
     prev = NULL;
     wsabuf = NULL;
@@ -26,7 +31,11 @@
     size = 0;
     bytes = 0;
 
-    ngx_init_array(io, c->pool, 10, sizeof(WSABUF), NGX_ERROR);
+    vec.elts = wsabufs;
+    vec.nelts = 0;
+    vec.size = sizeof(WSABUF);
+    vec.nalloc = NGX_WSABUFS; 
+    vec.pool = c->pool;
 
     /* coalesce the neighbouring bufs */
 
@@ -35,7 +44,11 @@
             wsabuf->len += chain->buf->end - chain->buf->last;
 
         } else {
-            ngx_test_null(wsabuf, ngx_push_array(&io), NGX_ERROR);
+            wsabuf = ngx_array_push(&vec);
+            if (wsabuf == NULL) {
+                return NGX_ERROR;
+            }
+
             wsabuf->buf = (char *) chain->buf->last;
             wsabuf->len = chain->buf->end - chain->buf->last;
         }
@@ -46,10 +59,10 @@
     }
 
     ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
-                   "WSARecv: %d:%d", io.nelts, wsabuf->len);
+                   "WSARecv: %d:%d", vec.nelts, wsabuf->len);
 
 
-    rc = WSARecv(c->fd, io.elts, io.nelts, &bytes, &flags, NULL, NULL);
+    rc = WSARecv(c->fd, vec.elts, vec.nelts, &bytes, &flags, NULL, NULL);
 
     rev = c->read;
 
diff --git a/src/os/win32/ngx_wsasend_chain.c b/src/os/win32/ngx_wsasend_chain.c
index d5b1334..bc3b015 100644
--- a/src/os/win32/ngx_wsasend_chain.c
+++ b/src/os/win32/ngx_wsasend_chain.c
@@ -12,8 +12,8 @@
 #define NGX_WSABUFS  8
 
 
-ngx_chain_t *ngx_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in,
-                               off_t limit)
+ngx_chain_t *
+ngx_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
 {
     int           rc;
     u_char       *prev;
@@ -22,9 +22,9 @@
     ngx_err_t     err;
     ngx_event_t  *wev;
     ngx_array_t   vec;
+    ngx_chain_t  *cl;
     LPWSABUF      wsabuf;
     WSABUF        wsabufs[NGX_WSABUFS];
-    ngx_chain_t  *cl;
 
     wev = c->write;
 
@@ -78,7 +78,8 @@
                 wsabuf->len += cl->buf->last - cl->buf->pos;
 
             } else {
-                if (!(wsabuf = ngx_array_push(&vec))) {
+                wsabuf = ngx_array_push(&vec);
+                if (wsabuf == NULL) {
                     return NGX_CHAIN_ERROR;
                 }
 
@@ -154,18 +155,18 @@
 }
 
 
-ngx_chain_t *ngx_overlapped_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in,
-                                          off_t limit)
+ngx_chain_t *
+ngx_overlapped_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
 {
     int               rc;
     u_char           *prev;
     u_long            size, send, sent;
-    LPWSABUF          wsabuf;
     ngx_err_t         err;
     ngx_event_t      *wev;
     ngx_array_t       vec;
     ngx_chain_t      *cl;
     LPWSAOVERLAPPED   ovlp;
+    LPWSABUF          wsabuf;
     WSABUF            wsabufs[NGX_WSABUFS];
 
     wev = c->write;
@@ -222,7 +223,8 @@
                 wsabuf->len += cl->buf->last - cl->buf->pos;
 
             } else {
-                if (!(wsabuf = ngx_array_push(&vec))) {
+                wsabuf = ngx_array_push(&vec);
+                if (wsabuf == NULL) {
                     return NGX_CHAIN_ERROR;
                 }