]> git.kaiwu.me - nginx.git/log
nginx.git
13 years agoVersion bump.
Maxim Dounin [Fri, 29 Mar 2013 15:29:29 +0000 (15:29 +0000)]
Version bump.

13 years agorelease-1.2.7 tag
Maxim Dounin [Tue, 12 Feb 2013 13:40:46 +0000 (13:40 +0000)]
release-1.2.7 tag

13 years agonginx-1.2.7-RELEASE release-1.2.7
Maxim Dounin [Tue, 12 Feb 2013 13:40:16 +0000 (13:40 +0000)]
nginx-1.2.7-RELEASE

13 years agoMerge of r5005, r5031, r5066: PCRE and OpenSSL for win32 builds.
Maxim Dounin [Mon, 11 Feb 2013 23:57:13 +0000 (23:57 +0000)]
Merge of r5005, r5031, r5066: PCRE and OpenSSL for win32 builds.

13 years agoMerge of r5027, r5028, r5029: fastcgi_keep_conn fixes.
Maxim Dounin [Mon, 11 Feb 2013 16:11:14 +0000 (16:11 +0000)]
Merge of r5027, r5028, r5029: fastcgi_keep_conn fixes.

*) FastCGI: fixed wrong connection close with fastcgi_keep_conn.

   With fastcgi_keep_conn it was possible that connection was closed after
   FCGI_STDERR record with zero padding and without any further data read
   yet.  This happended as f->state was set to ngx_http_fastcgi_st_padding
   and then "break" happened, resulting in p->length being set to
   f->padding, i.e. 0 (which in turn resulted in connection close).

   Fix is to make sure we continue the loop after f->state is set.

*) FastCGI: unconditional state transitions.  Checks for f->padding
   before state transitions make code hard to follow, remove them and
   make sure we always do another loop iteration after f->state is
   set to ngx_http_fastcgi_st_padding.

*) FastCGI: proper handling of split fastcgi end request.  If fastcgi
   end request record was split between several network packets, with
   fastcgi_keep_conn it was possible that connection was saved in
   incorrect state (e.g. with padding bytes not yet read).

13 years agoMerge of r5018: secure link: fixed configuration inheritance.
Maxim Dounin [Mon, 11 Feb 2013 16:09:35 +0000 (16:09 +0000)]
Merge of r5018: secure link: fixed configuration inheritance.

The "secure_link_secret" directive was always inherited from the outer
configuration level even when "secure_link" and "secure_link_md5" were
specified on the inner level.

13 years agoMerge of r5017: fixed null dereference with resolver and poll.
Maxim Dounin [Mon, 11 Feb 2013 16:06:39 +0000 (16:06 +0000)]
Merge of r5017: fixed null dereference with resolver and poll.

Events: fixed null pointer dereference with resolver and poll.

A POLLERR signalled by poll() without POLLIN/POLLOUT, as seen on
Linux, would generate both read and write events, but there's no
write event handler for resolver events.  A fix is to only call
event handler of an active event.

13 years agoMerge of r5014, r5015, r5016, r5030: geoip ipv6 support.
Maxim Dounin [Mon, 11 Feb 2013 15:34:30 +0000 (15:34 +0000)]
Merge of r5014, r5015, r5016, r5030: geoip ipv6 support.

*) Configure: fixed style of include directories.

*) Configure: fixed GeoIP library detection.

*) GeoIP: IPv6 support.  When using IPv6 databases, IPv4 addresses are
   looked up as IPv4-mapped IPv6 addresses.  Mostly based on a patch
   by Gregor Kališnik (ticket #250).

*) GeoIP: removed pseudo-support of "proxy" and "netspeed" databases.

13 years agoMerge of r5013: proxy: fixed proxy_method to always add space.
Maxim Dounin [Mon, 11 Feb 2013 15:31:10 +0000 (15:31 +0000)]
Merge of r5013: proxy: fixed proxy_method to always add space.

Before the patch if proxy_method was specified at http{} level the code
to add trailing space wasn't executed, resulting in incorrect requests
to upstream.

13 years agoMerge of r5012: configure: removed redundant variable assignment.
Maxim Dounin [Mon, 11 Feb 2013 15:28:50 +0000 (15:28 +0000)]
Merge of r5012: configure: removed redundant variable assignment.

13 years agoMerge of r5004, r5019-r5025: ssl fixes.
Maxim Dounin [Mon, 11 Feb 2013 15:12:06 +0000 (15:12 +0000)]
Merge of r5004, r5019-r5025: ssl fixes.

*) SSL: speedup loading of configs with many ssl servers.  The patch
   saves one EC_KEY_generate_key() call per server{} block by informing
   OpenSSL about SSL_OP_SINGLE_ECDH_USE we are going to use before
   the SSL_CTX_set_tmp_ecdh() call.

   For a configuration file with 10k simple server{} blocks with SSL
   enabled this change reduces startup time from 18s to 5s on a slow
   test box here.

*) SSL: removed conditions that always hold true.

*) SSL: resetting of flush flag after the data was written.  There is
   no need to flush next chunk of data if it does not contain a buffer
   with the flush or last_buf flags set.

*) SSL: preservation of flush flag for buffered data.  Previously,
   if SSL buffer was not sent we lost information that the data
   must be flushed.

*) SSL: calculation of buffer size moved closer to its usage.
   No functional changes.

*) SSL: avoid calling SSL_write() with zero data size.  According to
   documentation, calling SSL_write() with num=0 bytes to be sent
   results in undefined behavior.

   We don't currently call ngx_ssl_send_chain() with empty chain and
   buffer.  This check handles the case of a chain with total data size
   that is a multiple of NGX_SSL_BUFSIZE, and with the special buffer
   at the end.

   In practice such cases resulted in premature connection close and
   critical error "SSL_write() failed (SSL:)" in the error log.

*) SSL: take into account data in the buffer while limiting output.
   In some rare cases this can result in a more smooth sending rate.

*) SSL: fixed ngx_ssl_handshake() with level-triggered event methods.
   Missing calls to ngx_handle_write_event() and ngx_handle_read_event()
   resulted in a CPU hog during SSL handshake if an level-triggered event
   method (e.g. select) was used.

13 years agoMerge of r5001: year 2013.
Maxim Dounin [Mon, 11 Feb 2013 15:00:43 +0000 (15:00 +0000)]
Merge of r5001: year 2013.

13 years agoMerge of r4999, r5003: detect duplicate "events" and "keepalive".
Maxim Dounin [Mon, 11 Feb 2013 14:58:25 +0000 (14:58 +0000)]
Merge of r4999, r5003: detect duplicate "events" and "keepalive".

*) Upstream keepalive: detect duplicate "keepalive" directive.  A
   failure to detect duplicate "keepalive" directive resulted in
   stack exhaustion.

*) Events: added check for duplicate "events" directive.

13 years agoMerge of r4992: off-by-one with 32/64 upstream backup servers.
Maxim Dounin [Mon, 11 Feb 2013 14:56:14 +0000 (14:56 +0000)]
Merge of r4992: off-by-one with 32/64 upstream backup servers.

Fixed off-by-one during upstream state resetting when switching to
backup servers if there were exactly 32 (64 on 64-bit platforms)
backup servers configured.

Based on patch by Thomas Chen (ticket #257).

13 years agoMerge of r4991: fixed proxied HEAD requests with gzip enabled.
Maxim Dounin [Mon, 11 Feb 2013 14:39:49 +0000 (14:39 +0000)]
Merge of r4991: fixed proxied HEAD requests with gzip enabled.

Fixed HEAD requests handling when proxying is used (ticket #261).

13 years agoMerge of r4985, r4986, r4987, r4988, r4989, r5002: access_log gzip.
Maxim Dounin [Mon, 11 Feb 2013 14:34:00 +0000 (14:34 +0000)]
Merge of r4985, r4986, r4987, r4988, r4989, r5002: access_log gzip.

*) Access log: fixed redundant buffer reallocation.  Previously a new
   buffer was allocated for every "access_log" directive with the same
   file path and "buffer=" parameters, while only one buffer per file
   is used.

*) Reopening log files code moved to a separate function.  The code
   refactored in a way to call custom handler that can do appropriate
   cleanup work (if any), like flushing buffers, finishing compress
   streams, finalizing connections to log daemon, etc..

*) Access log: the "flush" parameter of the "access_log" directive.

*) Configure: added the NGX_ZLIB define.  This was introduced for
   conditional compilation of the code that requires the zlib library.

*) Access log: the "gzip" parameter of the "access_log" directive.
   Note: this requires zlib version 1.2.0.4 or above to work.

*) The data pointer in ngx_open_file_t objects must be initialized.
   Uninitialized pointer may result in arbitrary segfaults if access_log
   is used without buffer and without variables in file path.
   Patch by Tatsuhiko Kubo (ticket #268).

13 years agoMerge of r4979, r4982: image filter configuration inheritance.
Maxim Dounin [Mon, 11 Feb 2013 13:59:08 +0000 (13:59 +0000)]
Merge of r4979, r4982: image filter configuration inheritance.

*) Image filter: configuration inheritance fixes.

   The image_filter_jpeg_quality, image_filter_sharpen and
   "image_filter rotate" were inherited incorrectly if a directive
   with variables was defined, and then redefined to a literal value,
   i.e. in configurations like

       image_filter_jpeg_quality $arg_q;

       location / {
           image_filter_jpeg_quality 50;
       }

   Patch by Ian Babrou, with minor changes.

*) Image filter: fixed image_filter rotate inheritance.

   Configurations like

       location /i/ {
           image_filter resize 200 200;
           image_filter rotate 180;

           location /i/foo/ {
               image_filter resize 200 200;
           }
      }

   resulted in rotation incorrectly applied in the location /i/foo,
   without any way to clear it.  Fix is to handle conf->angle/conf->acv
   consistently with other filter variables and do not try to inherit
   them if there are transformations defined for current location.

13 years agoMerge of r4976: let add_header affect 201 responses (ticket #125).
Maxim Dounin [Mon, 11 Feb 2013 13:52:13 +0000 (13:52 +0000)]
Merge of r4976: let add_header affect 201 responses (ticket #125).

13 years agoMerge of r4983: crypt_r() error handling fixed.
Maxim Dounin [Mon, 11 Feb 2013 12:37:06 +0000 (12:37 +0000)]
Merge of r4983: crypt_r() error handling fixed.

The crypt_r() function returns NULL on errors, check it explicitly instead
of assuming errno will remain 0 if there are no errors (per POSIX, the
setting of errno after a successful call to a function is unspecified
unless the description of that function specifies that errno shall not
be modified).

Additionally, dropped unneeded ngx_set_errno(0) and fixed error handling
of memory allocation after normal crypt(), which was inapropriate and
resulted in null pointer dereference on allocation failures.

13 years agoMerge of r4974: avoid sending "100 Continue" on 413.
Maxim Dounin [Mon, 11 Feb 2013 12:35:49 +0000 (12:35 +0000)]
Merge of r4974: avoid sending "100 Continue" on 413.

Avoid sending "100 Continue" on 413 Request Entity Too Large.

Patch by Igor Sysoev.

13 years agoMerge of r4993, r4994, r4997, r5000: geo ipv6 support.
Maxim Dounin [Mon, 11 Feb 2013 12:31:43 +0000 (12:31 +0000)]
Merge of r4993, r4994, r4997, r5000: geo ipv6 support.

*) Geo: IPv6 support.  The "ranges" mode is still limited to IPv4 only.

*) Geo: properly initialize ngx_cidr_t when dealing with "default".

*) Geo: made "default" affect both IPv4 and IPv6 when using prefixes.
   Previously, "default" was equivalent to specifying 0.0.0.0/0, now
   it's equivalent to specifying both 0.0.0.0/0 and ::/0 (if support
   for IPv6 is enabled) with the same value.

*) Geo: improved code readability.

13 years agoMerge of r4968, r4969, r4977, r4980, r4981, r4990: geo fixes.
Maxim Dounin [Mon, 11 Feb 2013 12:26:33 +0000 (12:26 +0000)]
Merge of r4968, r4969, r4977, r4980, r4981, r4990: geo fixes.

*) Geo: improved ngx_http_geo_block() code readability.

*) Geo: fixed the "ranges" without ranges case.  The following
   configuration returned an empty value for $geo:

       geo $geo {
           ranges;
           default default;
       }

*) Fixed return type of internal function that allocates radix tree nodes.

*) There's no need to normalize address returned by ngx_ptocidr().

*) Geo: ensure that default entry is always present.  If 0.0.0.0/32 entry
   was present and there was no explicit "default", we failed to add an
   empty string as a default value.

*) Trailing whitespace fix.

13 years agoMerge of r4967: ngx_write_fd() and ngx_read_fd() errors handling.
Maxim Dounin [Sun, 10 Feb 2013 03:55:18 +0000 (03:55 +0000)]
Merge of r4967: ngx_write_fd() and ngx_read_fd() errors handling.

The ngx_write_fd() and ngx_read_fd() functions return -1 in case of error,
so the incorrect comparison with NGX_FILE_ERROR (which is 0 on windows
platforms) might result in inaccurate error message in the error log.

Also the ngx_errno global variable is being set only if the returned value
is -1.

13 years agoMerge of r4966: gzip: fixed zlib memLevel adjusting.
Maxim Dounin [Sun, 10 Feb 2013 03:52:26 +0000 (03:52 +0000)]
Merge of r4966: gzip: fixed zlib memLevel adjusting.

An incorrect memLevel (lower than 1) might be passed to deflateInit2() if the
"gzip_hash" directive is set to a value less than the value of "gzip_window"
directive. This resulted in "deflateInit2() failed: -2" alert and an empty
reply.

13 years agoMerge of r4965: upstream: fixed SIGSEGV with the "if" directive.
Maxim Dounin [Sun, 10 Feb 2013 03:27:15 +0000 (03:27 +0000)]
Merge of r4965: upstream: fixed SIGSEGV with the "if" directive.

Configuration like

    location / {
        set $true 1;

        if ($true) {
            proxy_pass http://backend;
        }

        if ($true) {
            # nothing
        }
    }

resulted in segmentation fault due to NULL pointer dereference as the
upstream configuration wasn't initialized in an implicit location created
by the last if(), but the r->content_handler was set due to first if().

Instead of committing a suicide by dereferencing a NULL pointer, return
500 (Internal Server Error) in such cases, i.e. if uscf is NULL.  Better
fix would be to avoid such cases by fixing the "if" directive handling,
but it's out of scope of this patch.

Prodded by Piotr Sikora.

13 years agoMerge of r4963: proxy: better error message about unexpected data.
Maxim Dounin [Sun, 10 Feb 2013 03:22:58 +0000 (03:22 +0000)]
Merge of r4963: proxy: better error message about unexpected data.

Requested by Igor Sysoev.

13 years agoMerge of r4962: limit_rate fix.
Maxim Dounin [Sun, 10 Feb 2013 03:20:00 +0000 (03:20 +0000)]
Merge of r4962: limit_rate fix.

Limit rate: fixed integer overflow in limit calculation (ticket #256).

Patch by Alexey Antropov.

13 years agoMerge of r4961: configure: better check for PCRE JIT.
Maxim Dounin [Sun, 10 Feb 2013 03:18:08 +0000 (03:18 +0000)]
Merge of r4961: configure: better check for PCRE JIT.

On Mac OS X system toolchain by default prefers include files
from /usr/local/include, but libraries from /usr/lib.  This might result in
various problems, in particular the one outlined below.

If the PCRE library is installed into /usr/local/, this results in pcre.h
being used from /usr/local/include (with PCRE_CONFIG_JIT defined), but
libpcre from /usr/lib (as shipped with the OS, without pcre_free_study()
symbol).  As a result build fails as we use pcre_free_study() function
if we try to compile with PCRE JIT support.

Obvious workaround to the root cause is to ask compiler to prefer
library from /usr/local/lib via ./configure --with-ld-opt="-L/usr/local/lib".
On the other hand, in any case it would be good to check if the function
we are going to use is available, hence the change.

See thread here for details:
http://mailman.nginx.org/pipermail/nginx-devel/2012-December/003074.html

Prodded by Piotr Sikora.

13 years agoMerge of r4948, r4949, r4964, r4973, r5011: variables.
Maxim Dounin [Sun, 10 Feb 2013 03:08:42 +0000 (03:08 +0000)]
Merge of r4948, r4949, r4964, r4973, r5011: variables.

*) Allow the complex value to be defined as an empty string.
   This makes conversion from strings to complex values possible
   without the loss of functionality.

*) The "auth_basic" directive gained support of variables.

*) Fixed variable syntax checking in "set", "geo", "limit_conn_zone",
   and "perl_set" directives.

*) Added checks that disallow adding a variable with an empty name.
   Added variable name syntax checks to "geo" and "map" directives.

*) Variables $pipe, $request_length, $time_iso8601, and $time_local.
   Log module counterparts are preserved for efficiency.
   Based on patch by Kiril Kalchev.

13 years agoMerge of r4947: xslt: prevented infinite loop.
Maxim Dounin [Sun, 10 Feb 2013 03:00:55 +0000 (03:00 +0000)]
Merge of r4947: xslt: prevented infinite loop.

If XSLT transformation failed and error 500 was handled in the same
location, an infinite loop occured that exhausted the stack.

13 years agoMerge of r4946, r4978: perl.
Maxim Dounin [Sun, 10 Feb 2013 02:58:03 +0000 (02:58 +0000)]
Merge of r4946, r4978: perl.

*) Fixed build with embedded perl in certain setups (ticket #48).

*) Brought the link to ngx_http_perl_module documentation up to date.

13 years agoMerge of r4945, r4984: ngx_inet.[ch] minor fixes.
Maxim Dounin [Sun, 10 Feb 2013 02:56:03 +0000 (02:56 +0000)]
Merge of r4945, r4984: ngx_inet.[ch] minor fixes.

*) Fixed the NGX_SOCKADDR_STRLEN macro definition.
   The ngx_sock_ntop() function, when told to print both address and port,
   prints IPv6 address in square brackets, followed by colon and port.

*) Properly initialize "struct in6_addr" with zeroes.

13 years agoMerge of r4944: removed GLOB_NOSORT glob option.
Maxim Dounin [Sat, 9 Feb 2013 21:27:37 +0000 (21:27 +0000)]
Merge of r4944: removed GLOB_NOSORT glob option.

This will result in alphabetical sorting of included files if
the "include" directive with wildcards is used.

Note that the behaviour is now different from that on Windows, where
alphabetical sorting is not guaranteed for FindFirsFile()/FindNextFile()
(used to be alphabetical on NTFS, but not on FAT).

Approved by Igor Sysoev, prodded by many.

13 years agoVersion bump.
Maxim Dounin [Sat, 9 Feb 2013 21:07:06 +0000 (21:07 +0000)]
Version bump.

13 years agorelease-1.2.6 tag
Maxim Dounin [Tue, 11 Dec 2012 14:26:07 +0000 (14:26 +0000)]
release-1.2.6 tag

13 years agonginx-1.2.6-RELEASE release-1.2.6
Maxim Dounin [Tue, 11 Dec 2012 14:24:23 +0000 (14:24 +0000)]
nginx-1.2.6-RELEASE

13 years agoMerge of r4921, r4922, r4923, r4924, r4925: request body fixes.
Maxim Dounin [Tue, 11 Dec 2012 13:18:50 +0000 (13:18 +0000)]
Merge of r4921, r4922, r4923, r4924, r4925: request body fixes.

*) Request body: fixed "501 Not Implemented" error handling.

   It is not about "Method" but a generic message, and is expected to be used
   e.g. if specified Transfer-Encoding is not supported.  Fixed message to
   match RFC 2616.

   Additionally, disable keepalive on such errors as we won't be able to read
   request body correctly if we don't understand Transfer-Encoding used.

*) Request body: $request_body variable generalization.

   The $request_body variable was assuming there can't be more than two
   buffers.  While this is currently true due to request body reading
   implementation details, this is not a good thing to depend on and may
   change in the future.

*) Request body: code duplication reduced, no functional changes.

   The r->request_body_in_file_only with empty body case is now handled in
   ngx_http_write_request_body().

*) Request body: fixed socket leak on errors.

   The r->main->count reference counter was always incremented in
   ngx_http_read_client_request_body(), while it is only needs to be
   incremented on positive returns.

*) Request body: properly handle events while discarding body.

   An attempt to call ngx_handle_read_event() before actually reading
   data from a socket might result in read event being disabled, which is
   wrong.  Catched by body.t test on Solaris.

13 years agoMerge of r4933, r4933: shared memory fixes.
Maxim Dounin [Mon, 10 Dec 2012 18:17:32 +0000 (18:17 +0000)]
Merge of r4933, r4933: shared memory fixes.

*) Fixed location of debug message in ngx_shmtx_lock().

*) Core: don't reuse shared memory zone that changed ownership (ticket #210).

   nginx doesn't allow the same shared memory zone to be used for different
   purposes, but failed to check this on reconfiguration.  If a shared memory
   zone was used for another purpose in the new configuration, nginx attempted
   to reuse it and crashed.

13 years agoMerge of r4920, r4939: ngx_write_chain_to_file() fixes.
Maxim Dounin [Mon, 10 Dec 2012 18:04:54 +0000 (18:04 +0000)]
Merge of r4920, r4939: ngx_write_chain_to_file() fixes.

*) Core: added debug logging of writev() in ngx_write_chain_to_file().

*) Core: fixed ngx_write_chain_to_file() with IOV_MAX reached.

   Catched by dav_chunked.t on Solaris.  In released versions this might
   potentially result in corruption of complex protocol responses if they
   were written to disk and there were more distinct buffers than IOV_MAX
   in a single write.

13 years agoMerge of r4919: fixed segfault on PUT in dav module.
Maxim Dounin [Mon, 10 Dec 2012 17:51:10 +0000 (17:51 +0000)]
Merge of r4919: fixed segfault on PUT in dav module.

Dav: fixed segfault on PUT if body was already read (ticket #238).

If request body reading happens with different options it's possible
that there will be no r->request_body->temp_file available (or even
no r->request_body available if body was discarded).  Return internal
server error in this case instead of committing suicide by dereferencing
a null pointer.

13 years agoMerge of r4918: cache manager startup with many listen sockets.
Maxim Dounin [Mon, 10 Dec 2012 17:46:51 +0000 (17:46 +0000)]
Merge of r4918: cache manager startup with many listen sockets.

Fixed failure to start cache manager and cache loader processes
if there were more than 512 listening sockets in configuration.

13 years agoMerge of r4915, r4916, r4917: upstream minor fixes.
Maxim Dounin [Mon, 10 Dec 2012 16:35:32 +0000 (16:35 +0000)]
Merge of r4915, r4916, r4917: upstream minor fixes.

*) Upstream: honor the "down" flag for a single server.

   If an upstream block was defined with the only server marked as
   "down", e.g.

       upstream u {
           server 127.0.0.1:8080 down;
       }

   an attempt was made to contact the server despite the "down" flag.
   It is believed that immediate 502 response is better in such a
   case, and it's also consistent with what is currently done in case
   of multiple servers all marked as "down".

*) Upstream: better detection of connect() failures with kqueue.

   Pending EOF might be reported on both read and write events, whichever
   comes first, so check both of them.

   Patch by Yichun Zhang (agentzh), slightly modified.

13 years agoMerge of r4914: variables $request_time and $msec.
Maxim Dounin [Mon, 10 Dec 2012 16:03:56 +0000 (16:03 +0000)]
Merge of r4914: variables $request_time and $msec.

Log module counterparts are preserved for efficiency.

13 years agoMerge of r4913: fixed CPU affinity on respawn of dead workers.
Maxim Dounin [Mon, 10 Dec 2012 16:00:55 +0000 (16:00 +0000)]
Merge of r4913: fixed CPU affinity on respawn of dead workers.

Worker processes are now made aware of their sequential number needed
to select CPU affinity mask.  This replaces a workaround from r4865.

13 years agoVersion bump.
Maxim Dounin [Mon, 10 Dec 2012 15:43:41 +0000 (15:43 +0000)]
Version bump.

13 years agorelease-1.2.5 tag
Maxim Dounin [Tue, 13 Nov 2012 13:35:19 +0000 (13:35 +0000)]
release-1.2.5 tag

13 years agonginx-1.2.5-RELEASE release-1.2.5
Maxim Dounin [Tue, 13 Nov 2012 13:34:59 +0000 (13:34 +0000)]
nginx-1.2.5-RELEASE

13 years agoMerge of r4896: event pipe: fixed handling of buf_to_file data.
Maxim Dounin [Tue, 13 Nov 2012 11:24:14 +0000 (11:24 +0000)]
Merge of r4896: event pipe: fixed handling of buf_to_file data.

Input filter might free a buffer if there is no data in it, and in case
of first buffer (used for cache header and request header, aka p->buf_to_file)
this resulted in cache corruption.  Buffer memory was reused to read upstream
response before headers were written to disk.

Fix is to avoid moving pointers in ngx_event_pipe_add_free_buf() to a buffer
start if we were asked to free a buffer used by p->buf_to_file.

This fixes occasional cache file corruption, usually resulted
in "cache file ... has md5 collision" alerts.

Reported by Anatoli Marinov.

13 years agoMerge of r4892: keepalive memory usage optimization.
Maxim Dounin [Tue, 13 Nov 2012 11:21:31 +0000 (11:21 +0000)]
Merge of r4892: keepalive memory usage optimization.

The ngx_http_keepalive_handler() function is now trying to not
keep c->buffer's memory for idle connections.

This behaviour is consistent with the ngx_http_set_keepalive()
function and it should decrease memory usage in some cases (especially
if epoll/rtsig is used).

13 years agoMerge of r4891: worker_processes auto.
Maxim Dounin [Tue, 13 Nov 2012 11:00:37 +0000 (11:00 +0000)]
Merge of r4891: worker_processes auto.

Core: the "auto" parameter of the "worker_processes" directive.

The parameter will set the number of worker processes to the
autodetected number of available CPU cores.

13 years agoMerge of r4886, r4887, r4894: log variables generalization:
Maxim Dounin [Tue, 13 Nov 2012 10:45:23 +0000 (10:45 +0000)]
Merge of r4886, r4887, r4894: log variables generalization:

*) Log: $apache_bytes_sent removed.  It was renamed to $body_bytes_sent
   in nginx 0.3.10 and the old name is deprecated since then.

*) Variable $bytes_sent.  It replicates variable $bytes_sent as previously
   available in log module only.  Patch by Benjamin Grössing (with minor
   changes).

*) Variables $connection and $connection_requests.  Log module
   counterparts are removed as they aren't used often and there is no
   need to preserve them for efficiency.

13 years agoMerge of r4885: ssl_verify_client optional_no_ca.
Maxim Dounin [Tue, 13 Nov 2012 10:42:16 +0000 (10:42 +0000)]
Merge of r4885: ssl_verify_client optional_no_ca.

SSL: the "ssl_verify_client" directive parameter "optional_no_ca".

This parameter allows to don't require certificate to be signed by
a trusted CA, e.g. if CA certificate isn't known in advance, like in
WebID protocol.

Note that it doesn't add any security unless the certificate is actually
checked to be trusted by some external means (e.g. by a backend).

Patch by Mike Kazantsev, Eric O'Connor.

13 years agoMerge of r4872, r4893: resolver cached addresses random rotation.
Maxim Dounin [Mon, 12 Nov 2012 18:47:07 +0000 (18:47 +0000)]
Merge of r4872, r4893: resolver cached addresses random rotation.

Resolver: cached addresses are returned with random rotation now.

This ensures balancing when working with dynamically resolved upstream
servers with multiple addresses.

Based on patch by Anton Jouline.

13 years agoMerge of r4870, r4871, r4890, r4895: minor fixes.
Maxim Dounin [Mon, 12 Nov 2012 18:39:51 +0000 (18:39 +0000)]
Merge of r4870, r4871, r4890, r4895: minor fixes.

*) Made sure to initialize the entire ngx_file_t structure.
   Found by Coverity.

*) Correct plural form for "path" in the whole source base.

*) Removed conditional compilation from waitpid() error test.

   There are reports that call to a signal handler for an exited process
   despite waitpid() already called for the process may happen on Linux
   as well.

*) Style, parentheses instead of braces in misc/GNUMakefile.

13 years agoMerge of r4868, r4869: SSL minor fixes.
Maxim Dounin [Mon, 12 Nov 2012 18:00:32 +0000 (18:00 +0000)]
Merge of r4868, r4869: SSL minor fixes.

*) SSL: fixed compression workaround to remove all methods.

   Previous code used sk_SSL_COMP_delete(ssl_comp_methods, i) while iterating
   stack from 0 to n, resulting in removal of only even compression methods.

   In real life this change is a nop, as there is only one compression method
   which is enabled by default in OpenSSL.

*) SSL: added version checks for ssl compression workaround.

   The SSL_COMP_get_compression_methods() is only available as an API
   function in OpenSSL 0.9.8+, require it explicitly to unbreak build
   with OpenSSL 0.9.7.

13 years agoMerge of r4866, r4867: configure fixes.
Maxim Dounin [Mon, 12 Nov 2012 17:57:57 +0000 (17:57 +0000)]
Merge of r4866, r4867: configure fixes.

*) Configure: help updated to list upstream keepalive and least_conn.
   Patch by Joshua Zhu.

*) Configure: additional test for ExtUtils::Embed perl module presence.
   Now perl configure will correctly fail if ExtUtils::Embed perl module
   is not present in the system (found on Amazon Linux AMI, as of
   release 2012.03).

13 years agoMerge of r4865: clearing of cpu_affinity after process spawn.
Maxim Dounin [Mon, 12 Nov 2012 17:54:49 +0000 (17:54 +0000)]
Merge of r4865: clearing of cpu_affinity after process spawn.

This fixes unwanted/incorrect cpu_affinity use on dead worker processes
respawn.  While this is not ideal, it's expected to be better when previous
situation where multiple processes were spawn with identical CPU affinity
set.

Reported by Charles Chen.

13 years agoVersion bump.
Maxim Dounin [Mon, 12 Nov 2012 17:03:38 +0000 (17:03 +0000)]
Version bump.

13 years agorelease-1.2.4 tag
Maxim Dounin [Tue, 25 Sep 2012 13:43:03 +0000 (13:43 +0000)]
release-1.2.4 tag

13 years agonginx-1.2.4-RELEASE release-1.2.4
Maxim Dounin [Tue, 25 Sep 2012 13:42:43 +0000 (13:42 +0000)]
nginx-1.2.4-RELEASE

13 years agoStable: removed gunzip module from win32 helper target.
Maxim Dounin [Tue, 25 Sep 2012 10:41:22 +0000 (10:41 +0000)]
Stable: removed gunzip module from win32 helper target.

Gunzip filter isn't merged into stable branch.

13 years agoMerge of r4835, r4841: improved welcome and 50x error pages.
Maxim Dounin [Mon, 24 Sep 2012 19:14:17 +0000 (19:14 +0000)]
Merge of r4835, r4841: improved welcome and 50x error pages.

13 years agoMerge of r4833: limit req: fix of rbtree node insertion.
Maxim Dounin [Mon, 24 Sep 2012 19:11:45 +0000 (19:11 +0000)]
Merge of r4833: limit req: fix of rbtree node insertion.

Limit req: fix of rbtree node insertion on hash collisions.

The rbtree used in ngx_http_limit_req_module has two level of keys, the top is
hash, and the next is the value string itself. However, when inserting a new
node, only hash has been set, while the value string has been left empty.

The bug was introduced in r4419 (1.1.14).
Found by Charles Chen.

13 years agoMerge of r4829: fixed strict aliasing with ipv6 (ticket #201).
Maxim Dounin [Mon, 24 Sep 2012 19:06:48 +0000 (19:06 +0000)]
Merge of r4829: fixed strict aliasing with ipv6 (ticket #201).

Fixed strict aliasing bugs when dealing with IPv4-mapped IPv6
addresses.

13 years agoMerge of r4828: "include" with wildcards in map and types blocks.
Maxim Dounin [Mon, 24 Sep 2012 19:05:02 +0000 (19:05 +0000)]
Merge of r4828: "include" with wildcards in map and types blocks.

The "include" directive should be able to include multiple files if
given a filename mask.  Fixed this to work for "include" directives
inside the "map" or "types" blocks.  The "include" directive inside
the "geo" block is still not fixed.

13 years agoMerge of r4817: geo: fixed handling of ranges without default set.
Maxim Dounin [Mon, 24 Sep 2012 19:02:16 +0000 (19:02 +0000)]
Merge of r4817: geo: fixed handling of ranges without default set.

The bug had appeared in 0.8.43 (r3653).  Patch by Weibin Yao.

13 years agoMerge of r4815: map: fixed optimization of variables as values.
Maxim Dounin [Mon, 24 Sep 2012 19:00:02 +0000 (19:00 +0000)]
Merge of r4815: map: fixed optimization of variables as values.

Previous code incorrectly used ctx->var_values as an array of pointers to
ngx_http_variable_value_t, but the array contains structures, not pointers.
Additionally, ctx->var_values inspection failed to properly set var on
match.

13 years agoMerge of r4813, r4814, r4818, r4819, r4820, r4823: mail fixes.
Maxim Dounin [Mon, 24 Sep 2012 18:58:13 +0000 (18:58 +0000)]
Merge of r4813, r4814, r4818, r4819, r4820, r4823: mail fixes.

*) Corrected the directive name in the ngx_mail_auth_http_module
   error message.

*) Don't let the well-known port in the "listen" directive to
   override the already set "protocol".

*) Fixed sorting of listen addresses (ticket #187).  For http module
   this problem was already fixed in r4756.

*) Removed a stale "AF_INET only" comment.  IPv6 client connections
   in mail modules have been supported since r2856.

*) Fixed handling of AF_UNIX addresses in "listen".  This makes AF_UNIX
   addresses in mail officially supported.

*) Whitespace fix.

13 years agoMerge of r4785, r4795, r4811, r4812, r4816, r4822: coverity.
Maxim Dounin [Mon, 24 Sep 2012 18:54:28 +0000 (18:54 +0000)]
Merge of r4785, r4795, r4811, r4812, r4816, r4822: coverity.

*) Resolver: fixed possible memory leak in ngx_resolver_create().

*) Explicitly ignore returned value from unlink() in ngx_open_tempfile().

*) Explicitly ignore returned value from close() in ngx_event_core_init_conf().

*) Added three missing checks for NULL after ngx_array_push() calls.

*) Crypt: fixed handling of corrupted SSHA entries in password file.

*) Mark logically dead code with corresponding comment.

Found by / prodded by Coverity.

13 years agoMerge of r4784: fixed the -p parameter handling.
Maxim Dounin [Mon, 24 Sep 2012 18:50:25 +0000 (18:50 +0000)]
Merge of r4784: fixed the -p parameter handling.

Ensure that the path supplied always ends with a `/' except when empty.
An empty value now corresponds to the current directory instead of `/'.

13 years agoMerge of r4842: fixed make macros to use parentheses.
Maxim Dounin [Mon, 24 Sep 2012 18:46:50 +0000 (18:46 +0000)]
Merge of r4842: fixed make macros to use parentheses.

Configure: fixed make macros to use parentheses instead of braces.
Parentheses are more portable, in particular they are understood by
nmake while braces aren't.

13 years agoMerge of r4779, r4840, r4843, r4844: win32 changes.
Maxim Dounin [Mon, 24 Sep 2012 18:37:14 +0000 (18:37 +0000)]
Merge of r4779, r4840, r4843, r4844: win32 changes.

*) Fixed build with Visual Studio 2005 Express.

   It is available via winetricks which makes it still usable, and has
   an old crtdefs.h which uses _CRT_SECURE_NO_DEPRECATE instead of
   _CRT_SECURE_NO_WARNINGS to suppress warnings.

   Reported by HAYASHI Kentaro,
   http://mailman.nginx.org/pipermail/nginx-devel/2012-August/002542.html

*) Configure: provide inflate() when building zlib on win32.

*) Helper target "win32" to run configure for win32 builds.

*) Updated zlib used for win32 builds.

13 years agoMerge of r4778, r4782, r4783, r4824, r4830, r4834: minor fixes.
Maxim Dounin [Mon, 24 Sep 2012 18:34:04 +0000 (18:34 +0000)]
Merge of r4778, r4782, r4783, r4824, r4830, r4834: minor fixes.

*) Reorder checks in ngx_shared_memory_add() for more consistent
   error messages.

*) Added "const" to ngx_memcpy() with NGX_MEMCPY_LIMIT defined.  This
   fixes warning produced during compilation of the ngx_http_geoip_module
   due to const qualifier being discarded.

*) Fixed possible use of old cached times if runtime went backwards.

   If ngx_time_sigsafe_update() updated only ngx_cached_err_log_time, and
   then clock was adjusted backwards, the cached_time[slot].sec might
   accidentally match current seconds on next ngx_time_update() call,
   resulting in various cached times not being updated.

   Fix is to clear the cached_time[slot].sec to explicitly mark cached times
   are stale and need updating.

*) Radix tree preallocation fix.  The preallocation size was calculated
   incorrectly and was always 8 due to sizeof(ngx_radix_tree_t) accidentally
   used instead of sizeof(ngx_radix_node_t).

*) Fixed overflow if ngx_slab_alloc() is called with very big "size"
   argument.

*) Write filter: replaced unneeded loop with one to free chains.
   Noted by Gabor Lekeny.

13 years agoMerge of r4777, r4780, r4831, r4832: release process changes.
Maxim Dounin [Mon, 24 Sep 2012 18:30:26 +0000 (18:30 +0000)]
Merge of r4777, r4780, r4831, r4832: release process changes.

*) Simplified makefile that builds CHANGES.

*) Removed the need in Perl to generate ZIP archive of nginx/Windows.

*) Converted DOS-style newlines in dump.xslt.

*) Pass changes.xml thru xmllint when generating CHANGES and CHANGES.ru.

13 years agoVersion bump.
Maxim Dounin [Mon, 24 Sep 2012 18:24:07 +0000 (18:24 +0000)]
Version bump.

13 years agorelease-1.2.3 tag
Maxim Dounin [Tue, 7 Aug 2012 12:36:19 +0000 (12:36 +0000)]
release-1.2.3 tag

13 years agonginx-1.2.3-RELEASE release-1.2.3
Maxim Dounin [Tue, 7 Aug 2012 12:35:56 +0000 (12:35 +0000)]
nginx-1.2.3-RELEASE

13 years agoMerge of r4739: s/ngx_shmtx_destory/ngx_shmtx_destroy/.
Maxim Dounin [Mon, 6 Aug 2012 18:09:23 +0000 (18:09 +0000)]
Merge of r4739: s/ngx_shmtx_destory/ngx_shmtx_destroy/.

13 years agoMerge of r4775: updated PCRE used for win32 builds.
Maxim Dounin [Mon, 6 Aug 2012 17:38:12 +0000 (17:38 +0000)]
Merge of r4775: updated PCRE used for win32 builds.

13 years agoMerge of r4771: ngx_http_find_virtual_server() fix.
Maxim Dounin [Mon, 6 Aug 2012 17:36:30 +0000 (17:36 +0000)]
Merge of r4771: ngx_http_find_virtual_server() fix.

The ngx_http_find_virtual_server() function should return NGX_DECLINED
if virtual server not found.

13 years agoMerge of r4770: hide_headers/pass_headers inheritance fix.
Maxim Dounin [Mon, 6 Aug 2012 17:34:08 +0000 (17:34 +0000)]
Merge of r4770: hide_headers/pass_headers inheritance fix.

Hide headers and pass headers arrays might not be inherited correctly
into a nested location, e.g. in configuration like

    server {
        proxy_hide_header X-Foo;
        location / {
            location /nested/ {
                proxy_pass_header X-Pad;
            }
        }
    }

the X-Foo header wasn't hidden in the location /nested/.

Reported by Konstantin Svist,
http://mailman.nginx.org/pipermail/nginx-ru/2012-July/047555.html

13 years agoMerge of r4769: better diagnostics for directives in wrong context.
Maxim Dounin [Mon, 6 Aug 2012 17:31:32 +0000 (17:31 +0000)]
Merge of r4769: better diagnostics for directives in wrong context.

13 years agoMerge of r4766, r4767: ngx_http_upstream_add() changes.
Maxim Dounin [Mon, 6 Aug 2012 17:20:01 +0000 (17:20 +0000)]
Merge of r4766, r4767: ngx_http_upstream_add() changes.

*) Fixed to return NULL if an error occurs.

*) Microoptimization: replaced an expression known to be constant with
   the constant value.

13 years agoMerge of r4765: reduced the number of preprocessor directives.
Maxim Dounin [Mon, 6 Aug 2012 17:15:23 +0000 (17:15 +0000)]
Merge of r4765: reduced the number of preprocessor directives.

13 years agoMerge of r4764: debug_connection with a domain name change.
Maxim Dounin [Mon, 6 Aug 2012 17:13:20 +0000 (17:13 +0000)]
Merge of r4764: debug_connection with a domain name change.

When "debug_connection" is configured with a domain name, only the first
resolved address was used.  Now all addresses will be used.

13 years agoMerge of r4763: added the Clang compiler support.
Maxim Dounin [Mon, 6 Aug 2012 17:10:35 +0000 (17:10 +0000)]
Merge of r4763: added the Clang compiler support.

The -Werror is commented out to not break builds on Linux.

13 years agoMerge of r4760, r4761: -Wmissing-prototypes.
Maxim Dounin [Mon, 6 Aug 2012 17:07:28 +0000 (17:07 +0000)]
Merge of r4760, r4761: -Wmissing-prototypes.

Fixed compilation with -Wmissing-prototypes.  Added a commented
out -Wmissing-prototypes to CFLAGS.  It is commented out to not break
builds with 3rd party modules.

13 years agoMerge of r4759, r4762, r4768: configure minor fixes.
Maxim Dounin [Mon, 6 Aug 2012 17:03:01 +0000 (17:03 +0000)]
Merge of r4759, r4762, r4768: configure minor fixes.

*) Replaced a number of "else if" with "elif".

*) Made sure to run configure in a "C" locale.  Otherwise, we may fail
   to properly detect a version of compiler.

*) Removed extraneous GCC warning flags.

13 years agoMerge of r4758: win32: fixed cpu hog after process startup failure.
Maxim Dounin [Mon, 6 Aug 2012 16:24:22 +0000 (16:24 +0000)]
Merge of r4758: win32: fixed cpu hog after process startup failure.

If ngx_spawn_process() failed while starting a process, the process
handle was closed but left non-NULL in the ngx_processes[] array.
The handle later was used in WaitForMultipleObjects() (if there
were multiple worker processes configured and at least one worker
process was started successfully), resulting in infinite loop.

Reported by Ricardo Villalobos Guevara:
http://mailman.nginx.org/pipermail/nginx-devel/2012-July/002494.html

13 years agoMerge of r4757: debugging messages in limit_conn.
Maxim Dounin [Mon, 6 Aug 2012 16:19:35 +0000 (16:19 +0000)]
Merge of r4757: debugging messages in limit_conn.

Fixed debugging messages to account that limit_zone was renamed to limit_conn.

13 years agoVersion bump.
Maxim Dounin [Mon, 6 Aug 2012 16:06:36 +0000 (16:06 +0000)]
Version bump.

13 years agoMerge of r4756: fixed listen addresses sorting (ticket #187)
Maxim Dounin [Mon, 6 Aug 2012 16:03:56 +0000 (16:03 +0000)]
Merge of r4756: fixed listen addresses sorting (ticket #187)

Fixed sorting of listen addresses so that wildcard address is always at
the end.  Failure to do so could result in several listen sockets to be
created instead of only one listening on wildcard address.

Reported by Roman Odaisky.

13 years agoMerge of r4754: synchronized the license text.
Maxim Dounin [Mon, 6 Aug 2012 15:52:02 +0000 (15:52 +0000)]
Merge of r4754: synchronized the license text.

Synchronized the license text with the FreeBSD's bsd-style-copyright.

13 years agoMerge of r4741: fixed "make" used instead of "${MAKE}".
Maxim Dounin [Mon, 6 Aug 2012 15:47:15 +0000 (15:47 +0000)]
Merge of r4741: fixed "make" used instead of "${MAKE}".

13 years agoMerge of r4740: fixed $request_length for pipelined requests.
Maxim Dounin [Mon, 6 Aug 2012 15:45:44 +0000 (15:45 +0000)]
Merge of r4740: fixed $request_length for pipelined requests.

13 years agoMerge of r4738: struct flock initialization.
Maxim Dounin [Mon, 6 Aug 2012 15:31:49 +0000 (15:31 +0000)]
Merge of r4738: struct flock initialization.

Made sure to initialize the entire "struct flock" allocated on stack.

13 years agoMerge of r4737: r->uri_changed in a named location fix.
Maxim Dounin [Mon, 6 Aug 2012 15:20:03 +0000 (15:20 +0000)]
Merge of r4737: r->uri_changed in a named location fix.

Reset r->uri_changed in a named location (ticket #184).

13 years agoMerge of r4736: typo fixed.
Maxim Dounin [Mon, 6 Aug 2012 14:58:36 +0000 (14:58 +0000)]
Merge of r4736: typo fixed.

13 years agoMerge of r4713: map hostnames fix (ticket #182).
Maxim Dounin [Mon, 6 Aug 2012 14:04:06 +0000 (14:04 +0000)]
Merge of r4713: map hostnames fix (ticket #182).

The final dot wasn't stripped before looking up in a map of hostnames.

13 years agorelease-1.2.2 tag
Maxim Dounin [Tue, 3 Jul 2012 10:48:54 +0000 (10:48 +0000)]
release-1.2.2 tag