changeset 334:42974b9e97b5 NGINX_0_5_37

nginx 0.5.37 *) Bugfix: if sub_filter and SSI were used together, then responses might were transferred incorrectly. *) Bugfix: large SSI inclusions might be truncated. *) Bugfix: worker processes might not catch reconfiguration and log rotation signals. *) Bugfix: nginx could not be built on latest Fedora 9 Linux. Thanks to Roxis. *) Bugfix: a segmentation fault might occur in worker process on Linux, if keepalive was enabled. *) Bugfix: an alert "sendmsg() failed (9: Bad file descriptor)" on some 64-bit platforms while reconfiguration.
author Igor Sysoev <http://sysoev.ru>
date Mon, 07 Jul 2008 00:00:00 +0400
parents 30e294abe0ca
children 90de406d5898
files CHANGES CHANGES.ru src/core/nginx.h src/http/modules/ngx_http_ssi_filter_module.c src/http/modules/ngx_http_sub_filter_module.c src/http/modules/perl/nginx.pm src/http/ngx_http_postpone_filter_module.c src/http/ngx_http_request.c src/os/unix/ngx_channel.c src/os/unix/ngx_freebsd_config.h src/os/unix/ngx_linux_config.h src/os/unix/ngx_posix_config.h src/os/unix/ngx_process_cycle.c
diffstat 13 files changed, 283 insertions(+), 196 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,24 @@
 
+Changes with nginx 0.5.37                                        07 Jul 2008
+
+    *) Bugfix: if sub_filter and SSI were used together, then responses 
+       might were transferred incorrectly.
+
+    *) Bugfix: large SSI inclusions might be truncated.
+
+    *) Bugfix: worker processes might not catch reconfiguration and log 
+       rotation signals.
+
+    *) Bugfix: nginx could not be built on latest Fedora 9 Linux.
+       Thanks to Roxis.
+
+    *) Bugfix: a segmentation fault might occur in worker process on Linux, 
+       if keepalive was enabled.
+
+    *) Bugfix: an alert "sendmsg() failed (9: Bad file descriptor)" on some 
+       64-bit platforms while reconfiguration.
+
+
 Changes with nginx 0.5.36                                        04 May 2008
 
     *) Bugfix: the "sub_filter" directive might set text to change into 
@@ -11,17 +31,17 @@ Changes with nginx 0.5.36               
        check a response length.
 
     *) Bugfix: nginx issued the bogus error message "SSL_shutdown() failed 
-       (SSL: )"; bug appeared in 0.5.35.
+       (SSL: )"; the bug had appeared in 0.5.35.
 
     *) Bugfix: in HTTPS mode requests might fail with the "bad write retry" 
-       error; bug appeared in 0.5.35.
+       error; the bug had appeared in 0.5.35.
 
     *) Bugfix: the "fastcgi_catch_stderr" directive did return error code; 
        now it returns 502 code, that can be rerouted to a next server using 
        the "fastcgi_next_upstream invalid_header" directive.
 
     *) Bugfix: a segmentation fault occurred in master process if the 
-       "fastcgi_catch_stderr" directive was used; bug appeared in 
+       "fastcgi_catch_stderr" directive was used; the bug had appeared in 
        0.5.32.
        Thanks to Manlio Perillo.
 
@@ -38,7 +58,7 @@ Changes with nginx 0.5.35               
        Thanks to Alexander V. Inyukhin.
 
     *) Bugfix: in HTTPS mode requests might fail with the "bad write retry" 
-       error; bug appeared in 0.5.13.
+       error; the bug had appeared in 0.5.13.
 
     *) Bugfix: the STARTTLS in SMTP mode did not work.
        Thanks to Oleg Motienko.
@@ -54,7 +74,7 @@ Changes with nginx 0.5.35               
        returned response in HTTP/0.9 version.
 
     *) Bugfix: if the "?" character was in a "error_page" directive, then 
-       it was escaped in a proxied request; bug appeared in 0.5.32.
+       it was escaped in a proxied request; the bug had appeared in 0.5.32.
 
 
 Changes with nginx 0.5.34                                        13 Dec 2007
@@ -83,7 +103,7 @@ Changes with nginx 0.5.34               
        server, then nginx returned usual response.
 
     *) Bugfix: URL double escaping in a redirect of the "msie_refresh" 
-       directive; bug appeared in 0.5.28.
+       directive; the bug had appeared in 0.5.28.
 
     *) Bugfix: a segmentation fault might occur in worker process if 
        subrequests were used.
@@ -147,8 +167,8 @@ Changes with nginx 0.5.33               
        memcached was used.
 
     *) Bugfix: nginx supported low case only "close" and "keep-alive" 
-       values in the "Connection" request header line; bug appeared in 
-       0.5.32.
+       values in the "Connection" request header line; the bug had appeared 
+       in 0.5.32.
 
     *) Bugfix: nginx could not start on Solaris if the shared PCRE library 
        located in non-standard place was used.
@@ -217,8 +237,8 @@ Changes with nginx 0.5.32               
        for HTTP and HTTPS, then nginx used only one port - 80 or 443.
 
     *) Bugfix: the "proxy_ignore_client_abort" and 
-       "fastcgi_ignore_client_abort" directives did not work; bug appeared 
-       in 0.5.13.
+       "fastcgi_ignore_client_abort" directives did not work; the bug had 
+       appeared in 0.5.13.
 
 
 Changes with nginx 0.5.31                                        15 Aug 2007
@@ -249,7 +269,7 @@ Changes with nginx 0.5.30               
        to the master process identification number.
 
     *) Bugfix: fix building on Solaris/amd64 by Sun Studio 11 and early 
-       versions; bug appeared in 0.5.29.
+       versions; the bug had appeared in 0.5.29.
 
 
 Changes with nginx 0.5.29                                        23 Jul 2007
@@ -301,7 +321,8 @@ Changes with nginx 0.5.26               
 Changes with nginx 0.5.25                                        11 Jun 2007
 
     *) Bugfix: nginx could not be built with the 
-       --without-http_rewrite_module parameter; bug appeared in 0.5.24.
+       --without-http_rewrite_module parameter; the bug had appeared in 
+       0.5.24.
 
 
 Changes with nginx 0.5.24                                        06 Jun 2007
@@ -310,7 +331,7 @@ Changes with nginx 0.5.24               
        was made using HTTP/0.9.
 
     *) Bugfix: a part of response body might be passed uncompressed if gzip 
-       was used; bug appeared in 0.5.23.
+       was used; the bug had appeared in 0.5.23.
 
 
 Changes with nginx 0.5.23                                        04 Jun 2007
@@ -333,8 +354,8 @@ Changes with nginx 0.5.23               
 
 Changes with nginx 0.5.22                                        29 May 2007
 
-    *) Bugfix: a big request body might not be passed to backend; bug 
-       appeared in 0.5.21.
+    *) Bugfix: a big request body might not be passed to backend; the bug 
+       had appeared in 0.5.21.
 
 
 Changes with nginx 0.5.21                                        28 May 2007
@@ -407,11 +428,12 @@ Changes with nginx 0.5.18               
 
     *) Bugfix: a segmentation fault occurred in master process after first 
        reconfiguration and receiving any signal if nginx was built with 
-       ngx_http_perl_module and perl did not support multiplicity; bug 
-       appeared in 0.5.9.
+       ngx_http_perl_module and perl did not support multiplicity; the bug 
+       had appeared in 0.5.9.
 
     *) Bugfix: if perl did not support multiplicity, then after 
-       reconfiguration perl code did not work; bug appeared in 0.3.38.
+       reconfiguration perl code did not work; the bug had appeared in 
+       0.3.38.
 
 
 Changes with nginx 0.5.17                                        02 Apr 2007
@@ -438,14 +460,14 @@ Changes with nginx 0.5.16               
 
     *) Bugfix: a segmentation fault might occur in worker process if a 
        charset was set in the "Content-Type" header line and the line has 
-       trailing ";"; bug appeared in 0.3.50.
+       trailing ";"; the bug had appeared in 0.3.50.
 
     *) Bugfix: the "[alert] zero size buf" error when FastCGI server was 
        used and a request body written in a temporary file was multiple of 
        32K.
 
     *) Bugfix: nginx could not be built on Solaris without the --with-debug 
-       option; bug appeared in 0.5.15.
+       option; the bug had appeared in 0.5.15.
 
 
 Changes with nginx 0.5.15                                        19 Mar 2007
@@ -501,17 +523,17 @@ Changes with nginx 0.5.13               
        send timeout only.
 
     *) Bugfix: nginx could not be built on platforms different from i386, 
-       amd64, sparc and ppc; bug appeared in 0.5.8.
+       amd64, sparc, and ppc; the bug had appeared in 0.5.8.
 
 
 Changes with nginx 0.5.12                                        12 Feb 2007
 
     *) Bugfix: nginx could not be built on platforms different from i386, 
-       amd64, sparc и ppc; bug appeared in 0.5.8.
+       amd64, sparc, and ppc; the bug had appeared in 0.5.8.
 
     *) Bugfix: a segmentation fault might occur in worker process if the 
-       temporarily files were used while working with FastCGI server; bug 
-       appeared in 0.5.8.
+       temporarily files were used while working with FastCGI server; the 
+       bug had appeared in 0.5.8.
 
     *) Bugfix: a segmentation fault might occur in worker process if the 
        $fastcgi_script_name variable was logged.
@@ -525,7 +547,7 @@ Changes with nginx 0.5.11               
        Thanks to Chris McGrath.
 
     *) Bugfix: the response was incorrect if several ranges were requested; 
-       bug appeared in 0.5.6.
+       the bug had appeared in 0.5.6.
 
     *) Bugfix: the "create_full_put_path" directive could not create the 
        intermediate directories if no "dav_access" directive was set.
@@ -541,10 +563,10 @@ Changes with nginx 0.5.11               
 Changes with nginx 0.5.10                                        26 Jan 2007
 
     *) Bugfix: while online executable file upgrade the new master process 
-       did not inherit the listening sockets; bug appeared in 0.5.9.
+       did not inherit the listening sockets; the bug had appeared in 0.5.9.
 
     *) Bugfix: a segmentation fault might occur in worker process if nginx 
-       was built with -O2 optimization; bug appeared in 0.5.1.
+       was built with -O2 optimization; the bug had appeared in 0.5.1.
 
 
 Changes with nginx 0.5.9                                         25 Jan 2007
@@ -580,7 +602,7 @@ Changes with nginx 0.5.8                
 
     *) Bugfix: if the "proxy_buffering off" directive was used and a client 
        connection was non-active, then the connection was closed after send 
-       timeout; bug appeared in 0.4.7.
+       timeout; the bug had appeared in 0.4.7.
 
     *) Bugfix: if the "epoll" method was used and a client closed a 
        connection prematurely, then nginx closed the connection after a 
@@ -661,7 +683,7 @@ Changes with nginx 0.5.4                
        directive, then nginx might report about configuration error.
 
     *) Bugfix: a segmentation fault might occur if the $host variable was 
-       used; bug appeared in 0.4.14.
+       used; the bug had appeared in 0.4.14.
 
 
 Changes with nginx 0.5.3                                         13 Dec 2006
@@ -678,8 +700,8 @@ Changes with nginx 0.5.3                
 Changes with nginx 0.5.2                                         11 Dec 2006
 
     *) Bugfix: if the "proxy_pass" directive used the name of the 
-       "upstream" block, then nginx tried to resolve the name; bug appeared 
-       in 0.5.1.
+       "upstream" block, then nginx tried to resolve the name; the bug had 
+       appeared in 0.5.1.
 
 
 Changes with nginx 0.5.1                                         11 Dec 2006
@@ -687,19 +709,20 @@ Changes with nginx 0.5.1                
     *) Bugfix: the "post_action" directive might not run after a 
        unsuccessful completion of a request.
 
-    *) Workaround: for Eudora for Mac; bug appeared in 0.4.11.
+    *) Workaround: for Eudora for Mac; the bug had appeared in 0.4.11.
        Thanks to Bron Gondwana.
 
     *) Bugfix: if the "upstream" name was used in the "fastcgi_pass", then 
-       the message "no port in upstream" was issued; bug appeared in 0.5.0.
+       the message "no port in upstream" was issued; the bug had appeared 
+       in 0.5.0.
 
     *) Bugfix: if the "proxy_pass" and "fastcgi_pass" directives used the 
        same servers but different ports, then these directives uses the 
-       first described port; bug appeared in 0.5.0.
+       first described port; the bug had appeared in 0.5.0.
 
     *) Bugfix: if the "proxy_pass" and "fastcgi_pass" directives used the 
        unix domain sockets, then these directives used first described 
-       socket; bug appeared in 0.5.0.
+       socket; the bug had appeared in 0.5.0.
 
     *) Bugfix: ngx_http_auth_basic_module ignored the user if it was in the 
        last line in the password file and there was no the carriage return, 
@@ -728,8 +751,8 @@ Changes with nginx 0.5.0                
     *) Feature: the WAIT status in the "Auth-Status" header line of the 
        IMAP/POP3 proxy authentication server response.
 
-    *) Bugfix: nginx could not be built on 64-bit platforms; bug appeared 
-       in 0.4.14.
+    *) Bugfix: nginx could not be built on 64-bit platforms; the bug had 
+       appeared in 0.4.14.
 
 
 Changes with nginx 0.4.14                                        27 Nov 2006
@@ -740,7 +763,7 @@ Changes with nginx 0.4.14               
        Linux, and NetBSD.
 
     *) Bugfix: ngx_http_perl_module did not work with perl built with the 
-       threads support; bug appeared in 0.3.38.
+       threads support; the bug had appeared in 0.3.38.
 
     *) Bugfix: ngx_http_perl_module did not work if perl was called 
        recursively.
@@ -775,7 +798,7 @@ Changes with nginx 0.4.13               
        the deferred accept() were used.
 
     *) Bugfix: a charset could not be set for ngx_http_autoindex_module 
-       responses; bug appeared in 0.3.50.
+       responses; the bug had appeared in 0.3.50.
 
     *) Bugfix: the "[alert] zero size buf" error when FastCGI server was 
        used;
@@ -783,8 +806,8 @@ Changes with nginx 0.4.13               
     *) Bugfix: the --group= configuration parameter was ignored.
        Thanks to Thomas Moschny.
 
-    *) Bugfix: the 50th subrequest in SSI response did not work; bug 
-       appeared in 0.3.50.
+    *) Bugfix: the 50th subrequest in SSI response did not work; the bug 
+       had appeared in 0.3.50.
 
 
 Changes with nginx 0.4.12                                        31 Oct 2006
@@ -805,7 +828,7 @@ Changes with nginx 0.4.11               
        method.
 
     *) Bugfix: if the APOP was enabled in the POP3 proxy, then the 
-       USER/PASS commands might not work; bug appeared in 0.4.10.
+       USER/PASS commands might not work; the bug had appeared in 0.4.10.
 
 
 Changes with nginx 0.4.10                                        23 Oct 2006
@@ -820,10 +843,10 @@ Changes with nginx 0.4.10               
        variable was used in the "map" directive.
 
     *) Bugfix: the ngx_http_flv_module did not support the byte ranges for 
-       full responses; bug appeared in 0.4.7.
-
-    *) Bugfix: nginx could not be built on Debian amd64; bug appeared in 
-       0.4.9.
+       full responses; the bug had appeared in 0.4.7.
+
+    *) Bugfix: nginx could not be built on Debian amd64; the bug had 
+       appeared in 0.4.9.
 
 
 Changes with nginx 0.4.9                                         13 Oct 2006
@@ -876,14 +899,14 @@ Changes with nginx 0.4.6                
        $r->headers_out("Content-Length", ...) method.
 
     *) Bugfix: after redirecting error by an "error_page" directive any 
-       ngx_http_rewrite_module directive returned this error code; bug 
-       appeared in 0.4.4.
+       ngx_http_rewrite_module directive returned this error code; the bug 
+       had appeared in 0.4.4.
 
 
 Changes with nginx 0.4.5                                         02 Oct 2006
 
-    *) Bugfix: nginx could not be built on Linux and Solaris; bug appeared 
-       in 0.4.4.
+    *) Bugfix: nginx could not be built on Linux and Solaris; the bug had 
+       appeared in 0.4.4.
 
 
 Changes with nginx 0.4.4                                         02 Oct 2006
@@ -918,7 +941,7 @@ Changes with nginx 0.4.3                
        error to the proxied server using a "proxy_pass" directive.
 
     *) Bugfix: a segmentation fault occurred if an unix domain socket was 
-       used in a "proxy_pass" directive; bug appeared in 0.3.47.
+       used in a "proxy_pass" directive; the bug had appeared in 0.3.47.
 
     *) Bugfix: SSI did work with memcached and nonbuffered responses.
 
@@ -927,8 +950,8 @@ Changes with nginx 0.4.3                
 
 Changes with nginx 0.4.2                                         14 Sep 2006
 
-    *) Bugfix: the O_NOATIME flag support on Linux was canceled; bug 
-       appeared in 0.4.1.
+    *) Bugfix: the O_NOATIME flag support on Linux was canceled; the bug 
+       had appeared in 0.4.1.
 
 
 Changes with nginx 0.4.1                                         14 Sep 2006
@@ -962,7 +985,7 @@ Changes with nginx 0.4.0                
 
     *) Bugfix: a segmentation fault occurred if there was an "index" 
        directive with variables and the first index name was without 
-       variables; bug appeared in 0.1.29.
+       variables; the bug had appeared in 0.1.29.
 
 
 Changes with nginx 0.3.61                                        28 Aug 2006
@@ -980,7 +1003,7 @@ Changes with nginx 0.3.61               
 Changes with nginx 0.3.60                                        18 Aug 2006
 
     *) Bugfix: a worker process may got caught in an endless loop while an 
-       error redirection; bug appeared in 0.3.59.
+       error redirection; the bug had appeared in 0.3.59.
 
 
 Changes with nginx 0.3.59                                        16 Aug 2006
@@ -992,7 +1015,7 @@ Changes with nginx 0.3.59               
 
     *) Bugfix: the "error_page" directive did not changes the 
        "Content-Type" header line after the "X-Accel-Redirect" was used; 
-       bug appeared in 0.3.58.
+       the bug had appeared in 0.3.58.
 
 
 Changes with nginx 0.3.58                                        14 Aug 2006
@@ -1060,8 +1083,8 @@ Changes with nginx 0.3.55               
        upstream.
 
     *) Bugfix: on some condition while reconfiguration character codes 
-       inside the "charset_map" may be treated invalid; bug appeared in 
-       0.3.50.
+       inside the "charset_map" may be treated invalid; the bug had 
+       appeared in 0.3.50.
 
 
 Changes with nginx 0.3.54                                        11 Jul 2006
@@ -1080,8 +1103,8 @@ Changes with nginx 0.3.54               
     *) Bugfix: the $upstream_response_time variable had the time of the 
        first request to a backend only.
 
-    *) Bugfix: nginx could not be built on amd64 platform; bug appeared in 
-       0.3.53.
+    *) Bugfix: nginx could not be built on amd64 platform; the bug had 
+       appeared in 0.3.53.
 
 
 Changes with nginx 0.3.53                                        07 Jul 2006
@@ -1114,10 +1137,10 @@ Changes with nginx 0.3.52               
        return the 405 error.
 
     *) Bugfix: the worker process may got caught in an endless loop if the 
-       limit rate was used; bug appeared in 0.3.37.
+       limit rate was used; the bug had appeared in 0.3.37.
 
     *) Bugfix: ngx_http_charset_module logged "unknown charset" alert, even 
-       if the recoding was not needed; bug appeared in 0.3.50.
+       if the recoding was not needed; the bug had appeared in 0.3.50.
 
     *) Bugfix: if a code response of the PUT request was 409, then a 
        temporary file was not removed.
@@ -1126,7 +1149,7 @@ Changes with nginx 0.3.52               
 Changes with nginx 0.3.51                                        30 Jun 2006
 
     *) Bugfix: the "<" symbols might disappeared some conditions in the 
-       SSI; bug appeared in 0.3.50.
+       SSI; the bug had appeared in 0.3.50.
 
 
 Changes with nginx 0.3.50                                        28 Jun 2006
@@ -1171,10 +1194,11 @@ Changes with nginx 0.3.48               
 
     *) Bugfix: the internal redirect always transform client's HTTP method 
        to GET, now the transformation is made for the "X-Accel-Redirect" 
-       redirects only and if the method is not HEAD; bug appeared in 0.3.42.
+       redirects only and if the method is not HEAD; the bug had appeared 
+       in 0.3.42.
 
     *) Bugfix: the ngx_http_perl_module could not be built, if the perl was 
-       built with the threads support; bug appeared in 0.3.46.
+       built with the threads support; the bug had appeared in 0.3.46.
 
 
 Changes with nginx 0.3.47                                        23 May 2006
@@ -1211,7 +1235,8 @@ Changes with nginx 0.3.45               
     *) Change: the &deg; symbol codes were changed in koi-win conversion 
        table.
 
-    *) Feature: the euro и N symbols were added to koi-win conversion table.
+    *) Feature: the euro and N symbols were added to koi-win conversion 
+       table.
 
     *) Bugfix: if nginx distributed the requests among several backends and 
        some backend failed, then requests intended for this backend was 
@@ -1288,9 +1313,9 @@ Changes with nginx 0.3.39               
 
     *) Bugfix: the active connection counter increased on the exceeding of 
        the connection limit specified by the "worker_connections" 
-       directive; bug appeared in 0.2.0.
-
-    *) Bugfix: the limit rate might not work on some condition; bug 
+       directive; the bug had appeared in 0.2.0.
+
+    *) Bugfix: the limit rate might not work on some condition; the bug had 
        appeared in 0.3.38.
 
 
@@ -1364,7 +1389,7 @@ Changes with nginx 0.3.36               
 Changes with nginx 0.3.35                                        22 Mar 2006
 
     *) Bugfix: the accept-filter and the TCP_DEFER_ACCEPT option were set 
-       for first "listen" directive only; bug appeared in 0.3.31.
+       for first "listen" directive only; the bug had appeared in 0.3.31.
 
     *) Bugfix: in the "proxy_pass" directive without the URI part in a 
        subrequest.
@@ -1389,7 +1414,7 @@ Changes with nginx 0.3.33               
 Changes with nginx 0.3.32                                        11 Mar 2006
 
     *) Bugfix: the debug logging on startup and reconfiguration time was 
-       removed; bug appeared in 0.3.31.
+       removed; the bug had appeared in 0.3.31.
 
 
 Changes with nginx 0.3.31                                        10 Mar 2006
@@ -1407,7 +1432,8 @@ Changes with nginx 0.3.31               
 
     *) 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; bug appeared in 0.3.18.
+       "*.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 
@@ -1425,7 +1451,7 @@ Changes with nginx 0.3.30               
        ngx_http_ssi_filter_module.
 
     *) Bugfix: nginx could not be built on i386 platform, if the PIC was 
-       used; bug appeared in 0.3.27.
+       used; the bug had appeared in 0.3.27.
 
 
 Changes with nginx 0.3.29                                        20 Feb 2006
@@ -1501,8 +1527,8 @@ Changes with nginx 0.3.26               
 Changes with nginx 0.3.25                                        01 Feb 2006
 
     *) Bugfix: the segmentation fault was occurred on start or while 
-       reconfiguration if there was invalid configuration; bug appeared in 
-       0.3.24.
+       reconfiguration if there was invalid configuration; the bug had 
+       appeared in 0.3.24.
 
 
 Changes with nginx 0.3.24                                        01 Feb 2006
@@ -1518,8 +1544,8 @@ Changes with nginx 0.3.24               
        location.
 
     *) Bugfix: on 64-bit platforms segmentation fault may occurred on start 
-       if the many names were used in the "server_name" directives; bug 
-       appeared in 0.3.18.
+       if the many names were used in the "server_name" directives; the bug 
+       had appeared in 0.3.18.
 
 
 Changes with nginx 0.3.23                                        24 Jan 2006
@@ -1542,8 +1568,8 @@ Changes with nginx 0.3.22               
        canceled.
 
     *) Bugfix: segmentation fault was occurred if the "none" or "blocked" 
-       values was specified in the "valid_referers" directive; bug appeared 
-       in 0.3.18.
+       values was specified in the "valid_referers" directive; the bug had 
+       appeared in 0.3.18.
 
 
 Changes with nginx 0.3.21                                        16 Jan 2006
@@ -1594,10 +1620,10 @@ Changes with nginx 0.3.18               
        ngx_http_map_module.
 
     *) Bugfix: segmentation fault was occurred if configuration file did 
-       not exist; bug appeared in 0.3.12.
+       not exist; the bug had appeared in 0.3.12.
 
     *) Bugfix: on 64-bit platforms segmentation fault may occurred on 
-       start; bug appeared in 0.3.16.
+       start; the bug had appeared in 0.3.16.
 
 
 Changes with nginx 0.3.17                                        18 Dec 2005
@@ -1608,8 +1634,8 @@ Changes with nginx 0.3.17               
     *) Feature: the "map" directive supports domain names in the 
        ".domain.tld" form.
 
-    *) Bugfix: the timeouts were not used in SSL handshake; bug appeared in 
-       0.2.4.
+    *) Bugfix: the timeouts were not used in SSL handshake; the bug had 
+       appeared in 0.2.4.
 
     *) Bugfix: in the HTTPS protocol in the "proxy_pass" directive.
 
@@ -1635,11 +1661,11 @@ Changes with nginx 0.3.16               
     *) Bugfix: the "config timefmt" SSI command set incorrect time format.
 
     *) Bugfix: nginx did not close connection to IMAP/POP3 backend for the 
-       SSL connections; bug appeared in 0.3.13.
+       SSL connections; the bug had appeared in 0.3.13.
        Thanks to Rob Mueller.
 
-    *) Bugfix: segmentation fault may occurred in at SSL shutdown; bug 
-       appeared in 0.3.13.
+    *) Bugfix: segmentation fault may occurred in at SSL shutdown; the bug 
+       had appeared in 0.3.13.
 
 
 Changes with nginx 0.3.15                                        07 Dec 2005
@@ -1655,8 +1681,8 @@ Changes with nginx 0.3.15               
 
 Changes with nginx 0.3.14                                        05 Dec 2005
 
-    *) Bugfix: in the 304 response the body was transferred; bug appeared 
-       in 0.3.13.
+    *) Bugfix: in the 304 response the body was transferred; the bug had 
+       appeared in 0.3.13.
 
 
 Changes with nginx 0.3.13                                        05 Dec 2005
@@ -1672,7 +1698,7 @@ Changes with nginx 0.3.13               
        request body to FastCGI-server via the unix domain socket.
 
     *) Bugfix: the "auth_basic" directive did not disable the 
-       authorization; bug appeared in 0.3.11.
+       authorization; the bug had appeared in 0.3.11.
 
 
 Changes with nginx 0.3.12                                        26 Nov 2005
@@ -1693,7 +1719,7 @@ Changes with nginx 0.3.12               
     *) Feature: the "proxy_buffering" directive.
 
     *) Bugfix: the changes in accept mutex handling when the "rtsig" method 
-       was used; bug appeared in 0.3.0.
+       was used; the bug had appeared in 0.3.0.
 
     *) Bugfix: if the client sent the "Transfer-Encoding: chunked" header 
        line, then nginx returns the 411 error.
@@ -1704,7 +1730,7 @@ Changes with nginx 0.3.12               
 
     *) Bugfix: if the "combined" format was explicitly specified in the 
        "access_log" directive, then the empty lines was written to the log; 
-       bug appeared in 0.3.8.
+       the bug had appeared in 0.3.8.
 
     *) Bugfix: nginx did not run on the sparc platform under any OS except 
        Solaris.
@@ -1716,7 +1742,7 @@ Changes with nginx 0.3.12               
 Changes with nginx 0.3.11                                        15 Nov 2005
 
     *) Bugfix: nginx did not pass the client request headers and body while 
-       proxying; bug appeared in 0.3.10.
+       proxying; the bug had appeared in 0.3.10.
 
 
 Changes with nginx 0.3.10                                        15 Nov 2005
@@ -1755,7 +1781,7 @@ Changes with nginx 0.3.10               
 Changes with nginx 0.3.9                                         10 Nov 2005
 
     *) Bugfix: nginx considered URI as unsafe if two any symbols was 
-       between two slashes; bug appeared in 0.3.8.
+       between two slashes; the bug had appeared in 0.3.8.
 
 
 Changes with nginx 0.3.8                                         09 Nov 2005
@@ -1795,8 +1821,8 @@ Changes with nginx 0.3.8                
 
     *) Bugfix: if the request URI was changes by the "rewrite" directive 
        and the request was proxied in location given by regular expression, 
-       then the incorrect request was transferred to backend; bug appeared 
-       in 0.2.6.
+       then the incorrect request was transferred to backend; the bug had 
+       appeared in 0.2.6.
 
     *) Bugfix: the "expires" directive did not remove the previous 
        "Expires" header.
@@ -1817,7 +1843,7 @@ Changes with nginx 0.3.7                
     *) Feature: the "access_log" supports the "buffer=" parameter.
 
     *) Bugfix: nginx could not be built on platforms different from i386, 
-       amd64, sparc и ppc; bug appeared in 0.3.2.
+       amd64, sparc, and ppc; the bug had appeared in 0.3.2.
 
 
 Changes with nginx 0.3.6                                         24 Oct 2005
@@ -1828,7 +1854,8 @@ Changes with nginx 0.3.6                
     *) Feature: the "log_format" supports the variables in the $name form.
 
     *) Bugfix: if at least in one server was no the "listen" directive, 
-       then nginx did not listen on the 80 port; bug appeared in 0.3.3.
+       then nginx did not listen on the 80 port; the bug had appeared in 
+       0.3.3.
 
     *) Bugfix: if the URI part is omitted in "proxy_pass" directive, the 
        the 80 port was always used.
@@ -1837,10 +1864,10 @@ Changes with nginx 0.3.6                
 Changes with nginx 0.3.5                                         21 Oct 2005
 
     *) Bugfix: the segmentation fault may occurred if the IMAP/POP3 login 
-       was changed by authorization server; bug appeared in 0.2.2.
+       was changed by authorization server; the bug had appeared in 0.2.2.
 
     *) Bugfix: the accept mutex did not work and all connections were 
-       handled by one process; bug appeared in 0.3.3.
+       handled by one process; the bug had appeared in 0.3.3.
 
     *) Bugfix: the timeout did not work if the "rtsig" method and the 
        "timer_resolution" directive were used.
@@ -1848,8 +1875,8 @@ Changes with nginx 0.3.5                
 
 Changes with nginx 0.3.4                                         19 Oct 2005
 
-    *) Bugfix: nginx could not be built on Linux 2.4+ and MacOS X; bug 
-       appeared in 0.3.3.
+    *) Bugfix: nginx could not be built on Linux 2.4+ and MacOS X; the bug 
+       had appeared in 0.3.3.
 
 
 Changes with nginx 0.3.3                                         19 Oct 2005
@@ -1870,7 +1897,7 @@ Changes with nginx 0.3.3                
        the CLOSED state.
 
     *) Bugfix: the mime type may be incorrectly set to default value for 
-       index file with variable in the name; bug appeared in 0.3.0.
+       index file with variable in the name; the bug had appeared in 0.3.0.
 
     *) Feature: the "timer_resolution" directive.
 
@@ -1902,7 +1929,8 @@ Changes with nginx 0.3.2                
 Changes with nginx 0.3.1                                         10 Oct 2005
 
     *) Bugfix: the segmentation fault occurred when the signal queue 
-       overflowed if the "rtsig" method was used; bug appeared in 0.2.0.
+       overflowed if the "rtsig" method was used; the bug had appeared in 
+       0.2.0.
 
     *) Change: correct handling of the "\\", "\"", "\'", and "\$" pairs in 
        SSI.
@@ -1936,7 +1964,7 @@ Changes with nginx 0.2.6                
     *) Bugfix: if the "set" directive set the ngx_http_geo_module variable 
        in some configuration part, the this variable was not available in 
        other configuration parts and the "using uninitialized variable" 
-       error was occurred; bug appeared in 0.2.2.
+       error was occurred; the bug had appeared in 0.2.2.
 
 
 Changes with nginx 0.2.5                                         04 Oct 2005
@@ -1958,17 +1986,17 @@ Changes with nginx 0.2.4                
     *) Feature: the ngx_http_ssi_module supports "$var=text", "$var!=text", 
        "$var=/text/", and "$var!=/text/" expressions in the "if" command.
 
-    *) Bugfix: in proxying location without trailing slash; bug appeared in 
-       0.1.44.
+    *) Bugfix: in proxying location without trailing slash; the bug had 
+       appeared in 0.1.44.
 
     *) Bugfix: the segmentation fault may occurred if the "rtsig" method 
-       was used; bug appeared in 0.2.0.
+       was used; the bug had appeared in 0.2.0.
 
 
 Changes with nginx 0.2.3                                         30 Sep 2005
 
     *) Bugfix: nginx could not be built without the --with-debug option; 
-       bug appeared in 0.2.2.
+       the bug had appeared in 0.2.2.
 
 
 Changes with nginx 0.2.2                                         30 Sep 2005
@@ -1997,8 +2025,8 @@ Changes with nginx 0.2.2                
 Changes with nginx 0.2.1                                         23 Sep 2005
 
     *) Bugfix: if all backend using in load-balancing failed after one 
-       error, then nginx may got caught in an endless loop; bug appeared in 
-       0.2.0.
+       error, then nginx may got caught in an endless loop; the bug had 
+       appeared in 0.2.0.
 
 
 Changes with nginx 0.2.0                                         23 Sep 2005
@@ -2076,7 +2104,7 @@ Changes with nginx 0.1.43               
     *) Bugfix: the segmentation fault occurred or the worker process may 
        got caught in an endless loop if the proxied or FastCGI server sent 
        the "Cache-Control" header line and the "expires" directive was 
-       used; in the proxied mode the bug appeared in 0.1.29.
+       used; in the proxied mode the the bug had appeared in 0.1.29.
 
 
 Changes with nginx 0.1.42                                        23 Aug 2005
@@ -2086,7 +2114,7 @@ Changes with nginx 0.1.42               
        occurred in the ngx_http_proxy_module.
 
     *) Bugfix: the "limit_rate" directive did not work inside the "if" 
-       block; bug appeared in 0.1.38.
+       block; the bug had appeared in 0.1.38.
 
 
 Changes with nginx 0.1.41                                        25 Jul 2005
@@ -2101,7 +2129,7 @@ Changes with nginx 0.1.40               
        information did not logged in the error log.
 
     *) Bugfix: the "Set-Cookie" header line was not transferred when the 
-       "X-Accel-Redirect" was used; bug appeared in 0.1.39.
+       "X-Accel-Redirect" was used; the bug had appeared in 0.1.39.
 
     *) Bugfix: the "Content-Disposition" header line was not transferred 
        when the "X-Accel-Redirect" was used.
@@ -2123,8 +2151,8 @@ Changes with nginx 0.1.39               
        transferred while the 401 response code redirecting.
 
     *) Bugfix: the ngx_http_proxy_module and ngx_http_fastcgi_module may 
-       close a connection before anything was transferred to a client; bug 
-       appeared in 0.1.38.
+       close a connection before anything was transferred to a client; the 
+       bug had appeared in 0.1.38.
 
     *) Workaround: the Linux glibc crypt_r() initialization bug.
 
@@ -2133,17 +2161,17 @@ Changes with nginx 0.1.39               
 
     *) Bugfix: if the backend response had the "Location" header line and 
        nginx should not rewrite this line, then the 500 code response body 
-       was transferred; bug appeared in 0.1.29.
+       was transferred; the bug had appeared in 0.1.29.
 
     *) Bugfix: some directives of the ngx_http_proxy_module and 
        ngx_http_fastcgi_module were not inherited from the server to the 
-       location level; bug appeared in 0.1.29.
+       location level; the bug had appeared in 0.1.29.
 
     *) Bugfix: the ngx_http_ssl_module did not support the certificate 
        chain.
 
     *) Bugfix: the ngx_http_autoindex_module did not show correctly the 
-       long file names; bug appeared in 0.1.38.
+       long file names; the bug had appeared in 0.1.38.
 
     *) Bugfixes in IMAP/POP3 proxy in interaction with a backend at the 
        login state.
@@ -2171,8 +2199,8 @@ Changes with nginx 0.1.38               
        than one remote subrequest.
 
     *) Bugfix: nginx treated the backend response as invalid if the status 
-       line in the header was transferred in two packets; bug appeared in 
-       0.1.29.
+       line in the header was transferred in two packets; the bug had 
+       appeared in 0.1.29.
 
     *) Feature: the "ssi_types" directive.
 
@@ -2226,7 +2254,7 @@ Changes with nginx 0.1.35               
     *) Feature: the "port_in_redirect" directive.
 
     *) Bugfix: the segmentation fault was occurred if the backend response 
-       header was in several packets; bug appeared in 0.1.29.
+       header was in several packets; the bug had appeared in 0.1.29.
 
     *) Bugfix: if more than 10 servers were configured or some server did 
        not use the "listen" directive, then the segmentation fault was 
@@ -2236,7 +2264,8 @@ Changes with nginx 0.1.35               
        bigger than the temporary file.
 
     *) Bugfix: nginx returned the 400 response on requests like 
-       "GET http://www.domain.com/uri HTTP/1.0"; bug appeared in 0.1.28.
+       "GET http://www.domain.com/uri HTTP/1.0"; the bug had appeared in 
+       0.1.28.
 
 
 Changes with nginx 0.1.34                                        26 May 2005
@@ -2256,7 +2285,7 @@ Changes with nginx 0.1.34               
 Changes with nginx 0.1.33                                        23 May 2005
 
     *) Bugfix: nginx could not be built with the --without-pcre parameter; 
-       bug appeared in 0.1.29.
+       the bug had appeared in 0.1.29.
 
     *) Bugfix: 3, 4, 7, and 8 the "proxy_set_header" directives in one 
        level cause the bus fault on start up.
@@ -2270,7 +2299,7 @@ Changes with nginx 0.1.33               
 Changes with nginx 0.1.32                                        19 May 2005
 
     *) Bugfix: the arguments were omitted in the redirects, issued by the 
-       "rewrite" directive; bug appeared in 0.1.29.
+       "rewrite" directive; the bug had appeared in 0.1.29.
 
     *) Feature: the "if" directive supports the captures in regular 
        expressions.
@@ -2291,7 +2320,7 @@ Changes with nginx 0.1.31               
     *) Bugfix: errors while using SSI and gzipping.
 
     *) Bugfix: the redirect with the 301 code was transferred without 
-       response body; bug appeared in 0.1.30.
+       response body; the bug had appeared in 0.1.30.
 
 
 Changes with nginx 0.1.30                                        14 May 2005
@@ -2303,7 +2332,8 @@ Changes with nginx 0.1.30               
 
     *) Bugfix: if the length of the response part received at once from 
        proxied or FastCGI server was equal to 500, then nginx returns the 
-       500 response code; in proxy mode the bug appeared in 0.1.29 only.
+       500 response code; in proxy mode the the bug had appeared in 0.1.29 
+       only.
 
     *) Bugfix: nginx did not consider the directives with 8 or 9 parameters 
        as invalid.
@@ -2382,7 +2412,7 @@ Changes with nginx 0.1.29               
        returned the 408 response.
 
     *) Bugfix: the segmentation fault was occurred if the backend sent an 
-       invalid line in response header; bug appeared in 0.1.26.
+       invalid line in response header; the bug had appeared in 0.1.26.
 
     *) Bugfix: the segmentation fault may occurred in FastCGI fault 
        tolerance configuration.
@@ -2502,7 +2532,7 @@ Changes with nginx 0.1.23               
        server name of the "server_name" directive.
 
     *) Bugfix: nginx could not be built on platforms different from i386, 
-       amd64, sparc и ppc; bug appeared in 0.1.22.
+       amd64, sparc, and ppc; the bug had appeared in 0.1.22.
 
     *) Bugfix: the ngx_http_autoindex_module now shows the information not 
        about the symlink, but about file or directory it points to.
@@ -2517,7 +2547,7 @@ Changes with nginx 0.1.22               
        connections statistics if the proxying or FastCGI server were used.
 
     *) Bugfix: the installation paths were incorrectly quoted on Linux and 
-       Solaris; bug appeared in 0.1.21.
+       Solaris; the bug had appeared in 0.1.21.
 
 
 Changes with nginx 0.1.21                                        22 Feb 2005
@@ -2602,7 +2632,8 @@ Changes with nginx 0.1.17               
        static page, then the segmentation fault occurred.
 
     *) Bugfix: if in a proxied "Location" header was a relative URL, then a 
-       host name and a slash were added to them; bug appeared in 0.1.14.
+       host name and a slash were added to them; the bug had appeared in 
+       0.1.14.
 
     *) Bugfix: the system error message was not logged on Linux.
 
@@ -2627,7 +2658,7 @@ Changes with nginx 0.1.16               
     *) Feature: the rewrite directive supports the arguments rewriting.
 
     *) Bugfix: the response code 400 was returned for the POST request with 
-       the "Content-Length: 0" header; bug appeared in 0.1.14.
+       the "Content-Length: 0" header; the bug had appeared in 0.1.14.
 
 
 Changes with nginx 0.1.15                                        19 Jan 2005
@@ -2648,8 +2679,8 @@ Changes with nginx 0.1.15               
        to use the regular expressions in locations.
 
     *) Bugfix: the directive "proxy_preserve_host  on" adds port 80 to the 
-       "Host" headers, if upstream listen on port 80; bug appeared in 
-       0.1.14.
+       "Host" headers, if upstream listen on port 80; the bug had appeared 
+       in 0.1.14.
 
     *) Bugfix: the same paths in autoconfiguration parameters 
        --http-client-body-temp-path=PATH and --http-proxy-temp-path=PATH, 
@@ -2675,7 +2706,8 @@ Changes with nginx 0.1.14               
        fastcgi_max_temp_file_size, fastcgi_temp_file_write_size, 
        fastcgi_next_upstream, and fastcgi_x_powered_by.
 
-    *) Bugfix: the "[alert] zero size buf" error; bug appeared in 0.1.3.
+    *) Bugfix: the "[alert] zero size buf" error; the bug had appeared in 
+       0.1.3.
 
     *) Change: the URI must be specified after the host name in the 
        proxy_pass directive.
@@ -2760,7 +2792,7 @@ Changes with nginx 0.1.10               
 
     *) Bugfix: if the request without arguments contains "//", "/./", 
        "/../" or "%XX" then the lost character in the request line was 
-       lost; bug appeared in 0.1.9.
+       lost; the bug had appeared in 0.1.9.
 
     *) Bugfix: the fix in 0.1.9 for the files bigger than 2G on Linux did 
        not work.
@@ -2778,7 +2810,8 @@ Changes with nginx 0.1.9                
        does not support sendfile64().
 
     *) Bugfix: while the build configuration on Linux the 
-       --with-poll_module parameter was required; bug appeared in 0.1.8.
+       --with-poll_module parameter was required; the bug had appeared in 
+       0.1.8.
 
 
 Changes with nginx 0.1.8                                         20 Nov 2004
@@ -2794,7 +2827,7 @@ Changes with nginx 0.1.8                
 Changes with nginx 0.1.7                                         12 Nov 2004
 
     *) Bugfix: on FreeBSD the segmentation fault may occur if the size of 
-       the transferred file was changed; bug appeared in 0.1.5.
+       the transferred file was changed; the bug had appeared in 0.1.5.
 
 
 Changes with nginx 0.1.6                                         11 Nov 2004
@@ -2853,13 +2886,13 @@ Changes with nginx 0.1.2                
     *) Bugfix: the portability improvements.
 
     *) Bugfix: if configuration file was set in command line, the 
-       reconfiguration was impossible; bug appeared in 0.1.1.
+       reconfiguration was impossible; the bug had appeared in 0.1.1.
 
     *) Bugfix: proxy module may get caught in an endless loop when sendfile 
        is not used.
 
     *) Bugfix: with sendfile the response was not recoded according to the 
-       charset module directives; bug appeared in 0.1.1.
+       charset module directives; the bug had appeared in 0.1.1.
 
     *) Bugfix: very seldom bug in the kqueue processing.
 
--- a/CHANGES.ru
+++ b/CHANGES.ru
@@ -1,4 +1,25 @@
 
+Изменения в nginx 0.5.37                                          07.07.2008
+
+    *) Исправление: при совместном использовании sub_filter и SSI ответы 
+       могли передаваться неверно.
+
+    *) Исправление: большие включения в SSI могли передавались не полностью.
+
+    *) Исправление: рабочие процессы могли не реагировать на сигналы 
+       переконфигурации и ротации логов.
+
+    *) Исправление: nginx не собирался на последних Fedora 9 Linux.
+       Спасибо Roxis.
+
+    *) Исправление: при использовании keepalive на Linux в рабочем процессе 
+       мог произойти segmentation fault.
+
+    *) Исправление: во время переконфигурации на некоторых 64-битном 
+       платформах в лог записывался alert "sendmsg() failed (9: Bad file 
+       descriptor)".
+
+
 Изменения в nginx 0.5.36                                          04.05.2008
 
     *) Исправление: директива sub_filter могла вставлять заменяемый текст в 
--- a/src/core/nginx.h
+++ b/src/core/nginx.h
@@ -8,7 +8,7 @@
 #define _NGINX_H_INCLUDED_
 
 
-#define NGINX_VERSION      "0.5.36"
+#define NGINX_VERSION      "0.5.37"
 #define NGINX_VER          "nginx/" NGINX_VERSION
 
 #define NGINX_VAR          "NGINX"
--- a/src/http/modules/ngx_http_ssi_filter_module.c
+++ b/src/http/modules/ngx_http_ssi_filter_module.c
@@ -558,8 +558,9 @@ ngx_http_ssi_body_filter(ngx_http_reques
                     if (b->in_file) {
                         if (slcf->min_file_chunk < (size_t) (b->last - b->pos))
                         {
-                            b->file_last = b->file_pos + (b->last - b->start);
-                            b->file_pos += b->pos - b->start;
+                            b->file_last = b->file_pos
+                                                   + (b->last - ctx->buf->pos);
+                            b->file_pos += b->pos - ctx->buf->pos;
 
                         } else {
                             b->in_file = 0;
--- a/src/http/modules/ngx_http_sub_filter_module.c
+++ b/src/http/modules/ngx_http_sub_filter_module.c
@@ -322,8 +322,8 @@ ngx_http_sub_body_filter(ngx_http_reques
                 b->recycled = 0;
 
                 if (b->in_file) {
-                    b->file_last = b->file_pos + (b->last - b->start);
-                    b->file_pos += b->pos - b->start;
+                    b->file_last = b->file_pos + (b->last - ctx->buf->pos);
+                    b->file_pos += b->pos - ctx->buf->pos;
                 }
 
                 cl->next = NULL;
--- a/src/http/modules/perl/nginx.pm
+++ b/src/http/modules/perl/nginx.pm
@@ -47,7 +47,7 @@ our @EXPORT = qw(
     HTTP_INSUFFICIENT_STORAGE
 );
 
-our $VERSION = '0.5.36';
+our $VERSION = '0.5.37';
 
 require XSLoader;
 XSLoader::load('nginx', $VERSION);
--- a/src/http/ngx_http_postpone_filter_module.c
+++ b/src/http/ngx_http_postpone_filter_module.c
@@ -168,7 +168,7 @@ ngx_http_postpone_filter_output_postpone
         pr = r->postponed;
 
         if (pr == NULL) {
-            return NGX_OK;
+            break;
         }
 
         if (pr->request) {
@@ -196,7 +196,7 @@ ngx_http_postpone_filter_output_postpone
         }
 
         if (pr == NULL) {
-            return NGX_OK;
+            break;
         }
 
         out = pr->out;
@@ -215,6 +215,17 @@ ngx_http_postpone_filter_output_postpone
 
         r->postponed = r->postponed->next;
     }
+
+    if (r->out) {
+        ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+                       "http postpone filter out again \"%V?%V\"",
+                       &r->uri, &r->args);
+
+        r->connection->data = r;
+        return NGX_AGAIN;
+    }
+
+    return NGX_OK;
 }
 
 
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -2046,7 +2046,8 @@ ngx_http_set_keepalive(ngx_http_request_
         hc->pipeline = 1;
         c->log->action = "reading client pipelined request line";
 
-        ngx_http_init_request(rev);
+        rev->handler = ngx_http_init_request;
+        ngx_post_event(rev, &ngx_posted_events);
         return;
     }
 
@@ -2156,7 +2157,7 @@ ngx_http_set_keepalive(ngx_http_request_
     c->idle = 1;
 
     if (rev->ready) {
-        ngx_http_keepalive_handler(rev);
+        ngx_post_event(rev, &ngx_posted_events);
     }
 }
 
--- a/src/os/unix/ngx_channel.c
+++ b/src/os/unix/ngx_channel.c
@@ -33,7 +33,7 @@ ngx_write_channel(ngx_socket_t s, ngx_ch
         msg.msg_control = (caddr_t) &cmsg;
         msg.msg_controllen = sizeof(cmsg);
 
-        cmsg.cm.cmsg_len = sizeof(cmsg);
+        cmsg.cm.cmsg_len = CMSG_LEN(sizeof(int));
         cmsg.cm.cmsg_level = SOL_SOCKET;
         cmsg.cm.cmsg_type = SCM_RIGHTS;
         *(int *) CMSG_DATA(&cmsg.cm) = ch->fd;
@@ -138,7 +138,7 @@ ngx_read_channel(ngx_socket_t s, ngx_cha
 
     if (ch->command == NGX_CMD_OPEN_CHANNEL) {
 
-        if (cmsg.cm.cmsg_len < (socklen_t) sizeof(cmsg)) {
+        if (cmsg.cm.cmsg_len < (socklen_t) CMSG_LEN(sizeof(int))) {
             ngx_log_error(NGX_LOG_ALERT, log, 0,
                           "recvmsg() returned too small ancillary data");
             return NGX_ERROR;
--- a/src/os/unix/ngx_freebsd_config.h
+++ b/src/os/unix/ngx_freebsd_config.h
@@ -48,11 +48,16 @@
 
 #if __FreeBSD_version < 400017
 
-/* FreeBSD 3.x has no CMSG_SPACE() at all and has the broken CMSG_DATA() */
+/*
+ * FreeBSD 3.x has no CMSG_SPACE() and CMSG_LEN() and has the broken CMSG_DATA()
+ */
 
 #undef  CMSG_SPACE
 #define CMSG_SPACE(l)       (ALIGN(sizeof(struct cmsghdr)) + ALIGN(l))
 
+#undef  CMSG_LEN
+#define CMSG_LEN(l)         (ALIGN(sizeof(struct cmsghdr)) + (l))
+
 #undef  CMSG_DATA
 #define CMSG_DATA(cmsg)     ((u_char *)(cmsg) + ALIGN(sizeof(struct cmsghdr)))
 
--- a/src/os/unix/ngx_linux_config.h
+++ b/src/os/unix/ngx_linux_config.h
@@ -47,6 +47,7 @@
 
 #include <time.h>               /* tzset() */
 #include <malloc.h>             /* memalign() */
+#include <limits.h>             /* IOV_MAX */
 #include <sys/ioctl.h>
 #include <sys/sysctl.h>
 #include <crypt.h>
--- a/src/os/unix/ngx_posix_config.h
+++ b/src/os/unix/ngx_posix_config.h
@@ -110,11 +110,16 @@
 
 #include <sys/param.h>          /* ALIGN() */
 
-/* FreeBSD 3.x has no CMSG_SPACE() at all and has the broken CMSG_DATA() */
+/* 
+ * FreeBSD 3.x has no CMSG_SPACE() and CMSG_LEN() and has the broken CMSG_DATA()
+ */
 
 #undef  CMSG_SPACE
 #define CMSG_SPACE(l)       (ALIGN(sizeof(struct cmsghdr)) + ALIGN(l))
 
+#undef  CMSG_LEN
+#define CMSG_LEN(l)         (ALIGN(sizeof(struct cmsghdr)) + (l))
+
 #undef  CMSG_DATA
 #define CMSG_DATA(cmsg)     ((u_char *)(cmsg) + ALIGN(sizeof(struct cmsghdr)))
 
--- a/src/os/unix/ngx_process_cycle.c
+++ b/src/os/unix/ngx_process_cycle.c
@@ -1055,65 +1055,74 @@ ngx_channel_handler(ngx_event_t *ev)
 
     ngx_log_debug0(NGX_LOG_DEBUG_CORE, ev->log, 0, "channel handler");
 
-    n = ngx_read_channel(c->fd, &ch, sizeof(ngx_channel_t), ev->log);
+    for ( ;; ) {
+
+        n = ngx_read_channel(c->fd, &ch, sizeof(ngx_channel_t), ev->log);
+
+        ngx_log_debug1(NGX_LOG_DEBUG_CORE, ev->log, 0, "channel: %i", n);
 
-    ngx_log_debug1(NGX_LOG_DEBUG_CORE, ev->log, 0, "channel: %i", n);
+        if (n == NGX_ERROR) {
+
+            if (ngx_event_flags & NGX_USE_EPOLL_EVENT) {
+                ngx_del_conn(c, 0);
+            }
 
-    if (n == NGX_ERROR) {
-        ngx_close_connection(c);
-        return;
-    }
+            ngx_close_connection(c);
+            return;
+        }
 
-    if (ngx_event_flags & NGX_USE_EVENTPORT_EVENT) {
-        if (ngx_add_event(ev, NGX_READ_EVENT, 0) == NGX_ERROR) {
+        if (ngx_event_flags & NGX_USE_EVENTPORT_EVENT) {
+            if (ngx_add_event(ev, NGX_READ_EVENT, 0) == NGX_ERROR) {
+                return;
+            }
+        }
+
+        if (n == NGX_AGAIN) {
             return;
         }
-    }
+
+        ngx_log_debug1(NGX_LOG_DEBUG_CORE, ev->log, 0,
+                       "channel command: %d", ch.command);
 
-    if (n == NGX_AGAIN) {
-        return;
-    }
+        switch (ch.command) {
 
-    ngx_log_debug1(NGX_LOG_DEBUG_CORE, ev->log, 0,
-                   "channel command: %d", ch.command);
-
-    switch (ch.command) {
+        case NGX_CMD_QUIT:
+            ngx_quit = 1;
+            break;
 
-    case NGX_CMD_QUIT:
-        ngx_quit = 1;
-        break;
+        case NGX_CMD_TERMINATE:
+            ngx_terminate = 1;
+            break;
 
-    case NGX_CMD_TERMINATE:
-        ngx_terminate = 1;
-        break;
+        case NGX_CMD_REOPEN:
+            ngx_reopen = 1;
+            break;
 
-    case NGX_CMD_REOPEN:
-        ngx_reopen = 1;
-        break;
+        case NGX_CMD_OPEN_CHANNEL:
 
-    case NGX_CMD_OPEN_CHANNEL:
-
-        ngx_log_debug3(NGX_LOG_DEBUG_CORE, ev->log, 0,
-                       "get channel s:%i pid:%P fd:%d", ch.slot, ch.pid, ch.fd);
+            ngx_log_debug3(NGX_LOG_DEBUG_CORE, ev->log, 0,
+                           "get channel s:%i pid:%P fd:%d",
+                           ch.slot, ch.pid, ch.fd);
 
-        ngx_processes[ch.slot].pid = ch.pid;
-        ngx_processes[ch.slot].channel[0] = ch.fd;
-        break;
+            ngx_processes[ch.slot].pid = ch.pid;
+            ngx_processes[ch.slot].channel[0] = ch.fd;
+            break;
 
-    case NGX_CMD_CLOSE_CHANNEL:
+        case NGX_CMD_CLOSE_CHANNEL:
 
-        ngx_log_debug4(NGX_LOG_DEBUG_CORE, ev->log, 0,
-                       "close channel s:%i pid:%P our:%P fd:%d",
-                       ch.slot, ch.pid, ngx_processes[ch.slot].pid,
-                       ngx_processes[ch.slot].channel[0]);
+            ngx_log_debug4(NGX_LOG_DEBUG_CORE, ev->log, 0,
+                           "close channel s:%i pid:%P our:%P fd:%d",
+                           ch.slot, ch.pid, ngx_processes[ch.slot].pid,
+                           ngx_processes[ch.slot].channel[0]);
 
-        if (close(ngx_processes[ch.slot].channel[0]) == -1) {
-            ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno,
-                          "close() channel failed");
+            if (close(ngx_processes[ch.slot].channel[0]) == -1) {
+                ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno,
+                              "close() channel failed");
+            }
+
+            ngx_processes[ch.slot].channel[0] = -1;
+            break;
         }
-
-        ngx_processes[ch.slot].channel[0] = -1;
-        break;
     }
 }