]> git.kaiwu.me - nginx.git/log
nginx.git
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

13 years agonginx-1.2.2-RELEASE release-1.2.2
Maxim Dounin [Tue, 3 Jul 2012 10:48:31 +0000 (10:48 +0000)]
nginx-1.2.2-RELEASE

13 years agoMerge of r4698: X-Forwarded-For conditionals.
Maxim Dounin [Mon, 2 Jul 2012 17:41:52 +0000 (17:41 +0000)]
Merge of r4698: X-Forwarded-For conditionals.

Fixed compile-time conditionals used to detect if X-Forwarded-For support
is needed.

Note: compatibility shims were added during merge to avoid possible
breakage of 3rd party modules.  At least cache purge module was broken
by the original commit, as it used to rely on NGX_HTTP_PROXY define.

13 years agoMerge of r4697: disabled gzip in OpenSSL prior to 1.0.0.
Maxim Dounin [Mon, 2 Jul 2012 17:25:51 +0000 (17:25 +0000)]
Merge of r4697: disabled gzip in OpenSSL prior to 1.0.0.

Disabled gzip compression in OpenSSL prior to 1.0.0 version.
This saves about 522K per connection.

13 years agoMerge of r4693: fixed "sendmsg() failed" alerts on HP-UX.
Maxim Dounin [Mon, 2 Jul 2012 17:22:31 +0000 (17:22 +0000)]
Merge of r4693: fixed "sendmsg() failed" alerts on HP-UX.

HP-UX needs _HPUX_ALT_XOPEN_SOCKET_API to be defined to be able to
use various POSIX versions of networking functions.  Notably sendmsg()
resulted in "sendmsg() failed (9: Bad file number)" alerts without it.

See xopen_networking(7) for more details.

13 years agoMerge of r4691: changed default alignment to 16.
Maxim Dounin [Mon, 2 Jul 2012 17:08:26 +0000 (17:08 +0000)]
Merge of r4691: changed default alignment to 16.

This fixes alignment problems observerd on ARMs, and likely also needed
for MIPSes.  Unless we know alignment is not required just assume we
need 16, which appears to be safe default for all architectures.

See here for details:
http://mailman.nginx.org/pipermail/nginx/2012-June/034139.html

13 years agoMerge of r4690: conflicting wildcard server names fix.
Maxim Dounin [Mon, 2 Jul 2012 16:59:34 +0000 (16:59 +0000)]
Merge of r4690: conflicting wildcard server names fix.

With previous code wildcard names were added to hash even if conflict
was detected.  This resulted in identical names in hash and segfault
later in ngx_hash_wildcard_init().

13 years agoMerge of r4688, r4689, r4706:
Maxim Dounin [Mon, 2 Jul 2012 16:56:53 +0000 (16:56 +0000)]
Merge of r4688, r4689, r4706:

*) Mp4: fixed non-keyframe seeks in some cases (ticket #175).

   Number of entries in stsc atom was wrong if we've added an entry to
   split a chunk.

   Additionally, there is no need to add an entry if we are going to split
   last chunk in an entry, it's enough to update the entry we already have.
   Previously new entry was added and old one was left as is, resulting in
   incorrect entry with zero chunks which might confuse some software.

*) Mp4: fixed streaming if moov atom is at buffer edge.

13 years agoMerge of r4686, r4687: $status variable.
Maxim Dounin [Mon, 2 Jul 2012 16:53:36 +0000 (16:53 +0000)]
Merge of r4686, r4687: $status variable.

Contains response status code as a 3-digit integer
(with leading zeroes if necessary), or one of the following values:

    000 - response status code has not yet been assigned
    009 - HTTP/0.9 request is being processed

13 years agoMerge of r4682, r4694, r4699, r4704, r4705: minor nits.
Maxim Dounin [Mon, 2 Jul 2012 16:51:02 +0000 (16:51 +0000)]
Merge of r4682, r4694, r4699, r4704, r4705: minor nits.

*) Fixed spelling of "endianness", and called it "byte ordering" in the
   user visible part.

*) Fixed return type of ngx_strerror_init().

*) Fixed a harmless error in spelling of "Connection: close" when computing
   the response header length.

*) Style.

*) Added code to look up Google perftools in /opt/local/, for MacPorts.

13 years agoMerge of r4655, r4656, r4657, r4695, r4696: upstream changes.
Maxim Dounin [Mon, 2 Jul 2012 16:41:13 +0000 (16:41 +0000)]
Merge of r4655, r4656, r4657, r4695, r4696: upstream changes.

*) Upstream: least_conn balancer module.

*) Upstream: weights and IPv6 support in ip_hash balancer.

*) Upstream keepalive: "single" parameter deprecated.

13 years agoMerge of r4654, r4672, r4684, r4685, r4692: resolver changes.
Maxim Dounin [Mon, 2 Jul 2012 16:23:14 +0000 (16:23 +0000)]
Merge of r4654, r4672, r4684, r4685, r4692: resolver changes.

*) Resolver: fixed format specification.
   Patch by Yichun Zhang (agentzh).

*) Support for IPv6 literals and an optional port in resolver.

*) Fixed crash in ngx_resolver_cleanup_tree().

   If sending a DNS request fails with an error (e.g., when mistakenly
   trying to send it to a local IP broadcast), such a request is not
   deleted if there are clients waiting on it.  However, it was still
   erroneously removed from the queue.  Later ngx_resolver_cleanup_tree()
   attempted to remove it from the queue again that resulted in a NULL
   pointer dereference.

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

*) Fixed segfault with poll and resolver used.

   Poll event method needs ngx_cycle->files to work, and use of
   ngx_exit_cycle without files set caused null pointer dereference in
   resolver's cleanup on udp socket close.

13 years agoMerge of r4671: support for IPv6 literals in proxy_pass and so on.
Maxim Dounin [Mon, 2 Jul 2012 16:16:27 +0000 (16:16 +0000)]
Merge of r4671: support for IPv6 literals in proxy_pass and so on.

13 years agoMerge of r4653: ngx_inet.c code reduction.
Maxim Dounin [Mon, 2 Jul 2012 16:11:02 +0000 (16:11 +0000)]
Merge of r4653: ngx_inet.c code reduction.

Code reduction (no functional changes).

13 years agoMerge of r4652: ssl without buffer should not set c->buffered.
Maxim Dounin [Mon, 2 Jul 2012 15:51:02 +0000 (15:51 +0000)]
Merge of r4652: ssl without buffer should not set c->buffered.

Removed mistaken setting of NGX_SSL_BUFFERED flag in ngx_ssl_send_chain()
if SSL buffer is not used.

13 years agoMerge of r4651: proxy_cookie_* fix.
Maxim Dounin [Mon, 2 Jul 2012 15:43:50 +0000 (15:43 +0000)]
Merge of r4651: proxy_cookie_* fix.

Fixed returned value handling from the cookie rewrite handler.

If the "proxy_cookie_domain" or "proxy_cookie_path" directive is used and there
are no matches in Set-Cookie header then ngx_http_proxy_rewrite_cookie() returns
NGX_DECLINED to indicate that the header was not rewritten. Returning this value
further from the upstream headers copy handler resulted in 500 error response.

See here for report:
http://mailman.nginx.org/pipermail/nginx/2012-May/033858.html

13 years agoMerge of r4648, r4649, r4650: memory leak with $geoip_org.
Maxim Dounin [Mon, 2 Jul 2012 15:41:31 +0000 (15:41 +0000)]
Merge of r4648, r4649, r4650: memory leak with $geoip_org.

Patch by Denis F. Latypoff (slightly modified).

13 years agoMerge of r4647: xslt reuse.
Maxim Dounin [Mon, 2 Jul 2012 15:39:28 +0000 (15:39 +0000)]
Merge of r4647: xslt reuse.

Fixed the reuse of parsed DTDs and XSLTs.

Patch by Kuramoto Eiji.

13 years agoMerge of r4646: jemalloc 3.0.0 compatibility.
Maxim Dounin [Mon, 2 Jul 2012 15:37:49 +0000 (15:37 +0000)]
Merge of r4646: jemalloc 3.0.0 compatibility.

Fixed compilation with -DNGX_DEBUG_MALLOC on FreeBSD 10.

After jemalloc 3.0.0 import there is no _malloc_options symbol, it has
been replaced with the malloc_conf one with a different syntax.

13 years agoMerge of r4644:
Maxim Dounin [Mon, 2 Jul 2012 15:35:22 +0000 (15:35 +0000)]
Merge of r4644:

Fixed potential null pointer dereference in ngx_resolver_create().
While here, improved error message.

13 years agoMerge of r4643:
Maxim Dounin [Mon, 2 Jul 2012 15:33:35 +0000 (15:33 +0000)]
Merge of r4643:

Removed historical and now redundant syntax pre-checks in ngx_parse_url().

13 years agoMerge of r4642:
Maxim Dounin [Mon, 2 Jul 2012 14:42:08 +0000 (14:42 +0000)]
Merge of r4642:

Fixed core variables dynamic access after reconfiguration.

If variable was indexed in previous configuration but not in current
one, the NGX_HTTP_VAR_INDEXED flag was left set and confused
ngx_http_get_variable().

Patch by Yichun Zhang (agentzh), slightly modified.

13 years agoMerge of r4639, r4640: C++ fixes.
Maxim Dounin [Fri, 29 Jun 2012 17:32:43 +0000 (17:32 +0000)]
Merge of r4639, r4640: C++ fixes.

Fixed the ngx_regex.h header file compatibility with C++.  Fixed
building --with-cpp_test_module on some systems.

13 years agoMerge of r4636, r4637, r4638: config sanity checks.
Maxim Dounin [Fri, 29 Jun 2012 17:28:41 +0000 (17:28 +0000)]
Merge of r4636, r4637, r4638: config sanity checks.

*) Added syntax checking of the second parameter of the "split_clients"
   directive.

*) Capped the status code that may be returned with "return" and
   "try_files".

*) Zero padded the returned and logged HTTP status code, and fixed possible
   buffer overrun in $status handling.

13 years agoMerge of r4645: fixed warning during nginx.xs compilation.
Maxim Dounin [Tue, 26 Jun 2012 14:40:23 +0000 (14:40 +0000)]
Merge of r4645: fixed warning during nginx.xs compilation.

13 years agoFixed misc/GNUmakefile to properly tag on stable-1.2 branch.
Maxim Dounin [Mon, 25 Jun 2012 15:41:17 +0000 (15:41 +0000)]
Fixed misc/GNUmakefile to properly tag on stable-1.2 branch.

13 years agoVersion bump.
Maxim Dounin [Mon, 25 Jun 2012 15:40:29 +0000 (15:40 +0000)]
Version bump.

13 years agoRetagged release-1.2.1 properly.
Maxim Dounin [Mon, 25 Jun 2012 15:35:27 +0000 (15:35 +0000)]
Retagged release-1.2.1 properly.

13 years agonginx-1.2.1-RELEASE
Maxim Dounin [Tue, 5 Jun 2012 14:01:45 +0000 (14:01 +0000)]
nginx-1.2.1-RELEASE

13 years agoMerge of r4674, r4675, r4676: win32 fixes.
Maxim Dounin [Tue, 5 Jun 2012 13:52:37 +0000 (13:52 +0000)]
Merge of r4674, r4675, r4676: win32 fixes.

*) Win32: disallowed access to various non-canonical name variants.

   This includes trailings dots and spaces, NTFS streams (and short names, as
   previously checked).  The checks are now also done in ngx_file_info(), thus
   allowing to use the "try_files" directive to protect external scripts.

*) Win32: normalization of trailing dot inside uri.

   Windows treats "/directory./" identical to "/directory/".  Do the same
   when working on Windows.  Note that the behaviour is different from one
   with last path component (where multiple spaces and dots are ignored by
   Windows).

*) Win32: uris with ":$" are now rejected.

   There are too many problems with special NTFS streams, notably "::$data",
   "::$index_allocation" and ":$i30:$index_allocation".

   For now we don't reject all URIs with ":" like Apache does as there are no
   good reasons seen yet, and there are multiple programs using it in URLs
   (e.g. MediaWiki).

13 years agoMerge of r4632: updated openssl used for win32 builds.
Maxim Dounin [Tue, 5 Jun 2012 13:17:05 +0000 (13:17 +0000)]
Merge of r4632: updated openssl used for win32 builds.

13 years agoMerge of r4630: fixed c->sent with unbuffered ssl.
Maxim Dounin [Mon, 4 Jun 2012 12:00:38 +0000 (12:00 +0000)]
Merge of r4630: fixed c->sent with unbuffered ssl.

Update c->sent in ngx_ssl_send_chain() even if SSL buffer is not used.

13 years agoMerge of r4614, r4624-r4629, r4631: proxy recursive changes.
Maxim Dounin [Mon, 4 Jun 2012 11:58:12 +0000 (11:58 +0000)]
Merge of r4614, r4624-r4629, r4631: proxy recursive changes.

*) Added IPv6 and UNIX-domain socket support in "debug_connection"
   directive.

*) New function ngx_http_get_forwarded_addr() to look up real client
   address.

   On input it takes an original address, string in the X-Forwarded-For format
   and its length, list of trusted proxies, and a flag indicating to perform
   the recursive search.  On output it returns NGX_OK and the "deepest" valid
   address in a chain, or NGX_DECLINED.  It supports AF_INET and AF_INET6.
   Additionally, original address and/or proxy may be specified as AF_UNIX.

*) Realip: chains of trusted proxies and IPv6 support.

   The module now supports recursive search of client address through
   the chain of trusted proxies, controlled by the "real_ip_recursive"
   directive (closes #2).  It also gets full IPv6 support (closes #44)
   and canonical value of the $client_addr variable on address change.

   Example:

       real_ip_header X-Forwarded-For;
       set_real_ip_from 127.0.0.0/8;
       set_real_ip_from ::1;
       set_real_ip_from unix:;
       real_ip_recursive on;

*) Geo: chains of trusted proxies and partial IPv6 support.

   The module now supports recursive search of client address through
   the chain of trusted proxies, controlled by the "proxy_recursive"
   directive in the "geo" block.  It also gets partial IPv6 support:
   now proxies may be specified with IPv6 addresses.

   Example:

       geo $test {
           ...
           proxy 127.0.0.1;
           proxy ::1;
           proxy_recursive;
       }

   There's also a slight change in behavior.  When original client
   address (as specified by the "geo" directive) is one of the
   trusted proxies, and the value of the X-Forwarded-For request
   header cannot not be parsed as a valid address, an original client
   address will be used for lookup.  Previously, 255.255.255.255 was
   used in this case.

*) Geoip: trusted proxies support and partial IPv6 support.

   The module now supports recursive search of client address through the
   chain of trusted proxies (closes #100), in the same scope as the geo
   module.  Proxies are listed by the "geoip_proxy" directive, recursive
   search is enabled by the "geoip_proxy_recursive" directive.  IPv6 is
   partially supported: proxies may be specified with IPv6 addresses.

   Example:

        geoip_country .../GeoIP.dat;
        geoip_proxy 127.0.0.1;
        geoip_proxy ::1;
        geoip_proxy 10.0.0.0/8;
        geoip_proxy_recursive on;

13 years agoMerge of r4622, r4623: balancing changes.
Maxim Dounin [Mon, 4 Jun 2012 11:21:58 +0000 (11:21 +0000)]
Merge of r4622, r4623: balancing changes.

*) Upstream: smooth weighted round-robin balancing.

   For edge case weights like { 5, 1, 1 } we now produce { a, a, b, a, c, a, a }
   sequence instead of { c, b, a, a, a, a, a } produced previously.

   Algorithm is as follows: on each peer selection we increase current_weight
   of each eligible peer by its weight, select peer with greatest current_weight
   and reduce its current_weight by total number of weight points distributed
   among peers.

   In case of { 5, 1, 1 } weights this gives the following sequence of
   current_weight's:

        a  b  c
        0  0  0  (initial state)

        5  1  1  (a selected)
       -2  1  1

        3  2  2  (a selected)
       -4  2  2

        1  3  3  (b selected)
        1 -4  3

        6 -3  4  (a selected)
       -1 -3  4

        4 -2  5  (c selected)
        4 -2 -2

        9 -1 -1  (a selected)
        2 -1 -1

        7  0  0  (a selected)
        0  0  0

   To preserve weight reduction in case of failures the effective_weight
   variable was introduced, which usually matches peer's weight, but is
   reduced temporarily on peer failures.

   This change also fixes loop with backup servers and proxy_next_upstream
   http_404 (ticket #47), and skipping alive upstreams in some cases if there
   are multiple dead ones (ticket #64).

*) Upstream: fixed ip_hash rebalancing with the "down" flag.

   Due to weight being set to 0 for down peers, order of peers after sorting
   wasn't the same as without the "down" flag (with down peers at the end),
   resulting in client rebalancing for clients on other servers.  The only
   rebalancing which should happen after adding "down" to a server is one
   for clients on the server.

   The problem was introduced in r1377 (which fixed endless loop by setting
   weight to 0 for down servers).  The loop is no longer possible with new
   smooth algorithm, so preserving original weight is safe.

13 years agoMerge of r4621, r4641: filter_finalize fixes.
Maxim Dounin [Mon, 4 Jun 2012 11:15:46 +0000 (11:15 +0000)]
Merge of r4621, r4641: filter_finalize fixes.

*) Fixed possible request hang with filter finalization.

   With r->filter_finalize set the ngx_http_finalize_connection() wasn't
   called from ngx_http_finalize_request() called with NGX_OK, resulting in
   r->main->count not being decremented, thus causing request hang in some
   rare situations.

   Patch by Yichun Zhang (agentzh).

*) Fixed segfault with filter_finalize introduced in r4621 (1.3.0).

See the following thread for more details:
http://mailman.nginx.org/pipermail/nginx-devel/2012-May/002190.html

13 years agoMerge of r4619: accept moderation on EMFILE/ENFILE.
Maxim Dounin [Mon, 4 Jun 2012 11:10:36 +0000 (11:10 +0000)]
Merge of r4619: accept moderation on EMFILE/ENFILE.

In case of EMFILE/ENFILE returned from accept() we disable accept events,
and (in case of no accept mutex used) arm timer to re-enable them later.
With accept mutex we just drop it, and rely on normal accept mutex handling
to re-enable accept events once it's acquired again.

As we now handle errors in question, logging level was changed to "crit"
(instead of "alert" used for unknown errors).

Note: the code might call ngx_enable_accept_events() multiple times if
there are many listen sockets.  The ngx_enable_accept_events() function was
modified to check if connection is already active (via c->read->active) and
skip it then, thus making multiple calls safe.

13 years agoMerge of r4618: rewrite escaping fix (ticket #162).
Maxim Dounin [Mon, 4 Jun 2012 11:07:19 +0000 (11:07 +0000)]
Merge of r4618: rewrite escaping fix (ticket #162).

The following code resulted in incorrect escaping of uri and possible
segfault:

    location / {
        rewrite ^(.*) $1?c=$1;
        return 200 "$uri";
    }

If there were arguments in a rewrite's replacement string, and length was
actually calculated (due to duplicate captures as in the example above,
or variables present), the is_args flag was set and incorrectly copied
after length calculation.  This resulted in escaping applied to the uri part
of the replacement, resulting in incorrect escaping.  Additionally, buffer
was allocated without escaping expected, thus this also resulted in buffer
overrun and possible segfault.

13 years agoMerge of r4617: fastcgi padding fix.
Maxim Dounin [Mon, 4 Jun 2012 11:00:34 +0000 (11:00 +0000)]
Merge of r4617: fastcgi padding fix.

Fastcgi: fixed padding handling on fixed-size records.

Padding was incorrectly ignored on end request, empty stdout and stderr
fastcgi records.  This resulted in protocol desynchronization if fastcgi
application used these records with padding for some reason.

Reported by Ilia Vinokurov.

13 years agoMerge of r4616: r->state fix.
Maxim Dounin [Mon, 4 Jun 2012 10:54:48 +0000 (10:54 +0000)]
Merge of r4616: r->state fix.

Added r->state reset on fastcgi/scgi/uwsgi request start.

Failing to do so results in problems if 400 or 414 requests are
redirected to fastcgi/scgi/uwsgi upstream, as well as after invalid
headers got from upstream.  This was already fixed for proxy in r3478,
but fastcgi (the only affected protocol at that time) was missed.

Reported by Matthieu Tourne.

13 years agoMerge of r4615: write handler reset in ngx_http_named_location().
Maxim Dounin [Mon, 4 Jun 2012 10:52:43 +0000 (10:52 +0000)]
Merge of r4615: write handler reset in ngx_http_named_location().

On internal redirects this happens via ngx_http_handler() call, which is
not called on named location redirect.  As a result incorrect write handler
remained (if previously set) and this might cause incorrect behaviour (likely
request hang).

Patch by Yichun Zhang (agentzh).

13 years agoMerge of r4613: removed surplus condition.
Maxim Dounin [Mon, 4 Jun 2012 10:33:38 +0000 (10:33 +0000)]
Merge of r4613: removed surplus condition.

13 years agoMerge of r4612: proper subrequest handling in various modules.
Maxim Dounin [Mon, 4 Jun 2012 10:27:00 +0000 (10:27 +0000)]
Merge of r4612: proper subrequest handling in various modules.

13 years agoMerge of r4611, r4620: resolver fixes.
Maxim Dounin [Mon, 4 Jun 2012 10:15:55 +0000 (10:15 +0000)]
Merge of r4611, r4620: resolver fixes.

*) Fixed segmentation fault in ngx_resolver_create_name_query().

   If name passed for resolution was { 0, NULL } (e.g. as a result
   of name server returning CNAME pointing to ".") pointer wrapped
   to (void *) -1 resulting in segmentation fault on an attempt to
   dereference it.

   Reported by Lanshun Zhou.

*) Resolver: protection from duplicate responses.

   If we already had CNAME in resolver node (i.e. rn->cnlen and rn->u.cname
   set), and got additional response with A record, it resulted in rn->cnlen
   set and rn->u.cname overwritten by rn->u.addr (or rn->u.addrs), causing
   segmentation fault later in ngx_resolver_free_node() on an attempt to free
   overwritten rn->u.cname.  The opposite (i.e. CNAME got after A) might cause
   similar problems as well.

13 years agoVersion bump.
Maxim Dounin [Mon, 4 Jun 2012 10:00:39 +0000 (10:00 +0000)]
Version bump.

14 years agostable-1.2 branch
Maxim Dounin [Thu, 26 Apr 2012 11:18:21 +0000 (11:18 +0000)]
stable-1.2 branch

14 years agorelease-1.2.0 tag
Maxim Dounin [Mon, 23 Apr 2012 13:07:07 +0000 (13:07 +0000)]
release-1.2.0 tag

14 years agonginx-1.2.0-RELEASE release-1.2.0
Maxim Dounin [Mon, 23 Apr 2012 13:06:47 +0000 (13:06 +0000)]
nginx-1.2.0-RELEASE

14 years agoVersion bump.
Maxim Dounin [Mon, 23 Apr 2012 12:54:14 +0000 (12:54 +0000)]
Version bump.

14 years agoFix of "%f" format handling.
Igor Sysoev [Mon, 23 Apr 2012 11:11:32 +0000 (11:11 +0000)]
Fix of "%f" format handling.

ngx_sprintf("%.2f", 0.999) incorrectly resulted in "0.100" instead of "1.00".

14 years agoUpdate openssl used for win32 builds.
Maxim Dounin [Mon, 23 Apr 2012 11:05:21 +0000 (11:05 +0000)]
Update openssl used for win32 builds.

14 years agoProxy: added ctx checking to input filters.
Maxim Dounin [Mon, 23 Apr 2012 10:40:01 +0000 (10:40 +0000)]
Proxy: added ctx checking to input filters.

The proxy module context may be NULL in case of filter finalization
(e.g. by image_filter) followed by an internal redirect.  This needs
some better handling, but for now just check if ctx is still here.

14 years agoImage filter: compare aspect ratio more accurately during crop.
Maxim Dounin [Sat, 21 Apr 2012 19:02:21 +0000 (19:02 +0000)]
Image filter: compare aspect ratio more accurately during crop.

Previously used fixed-point calculation caused wrong code path selection
in some cases, resulting in incorrect image size.

See here for report:
http://mailman.nginx.org/pipermail/nginx-devel/2012-April/002123.html

14 years agoFixed segfault with try_files (ticket #152).
Maxim Dounin [Thu, 19 Apr 2012 15:48:03 +0000 (15:48 +0000)]
Fixed segfault with try_files (ticket #152).

The problem occured if first uri in try_files was shorter than request uri,
resulting in reserve being 0 and hence allocation skipped.  The bug was
introduced in r4584 (1.1.19).

14 years agoFixed master exit if there is no events section (ticket #150).
Maxim Dounin [Wed, 18 Apr 2012 14:47:10 +0000 (14:47 +0000)]
Fixed master exit if there is no events section (ticket #150).

Instead of checking if there is events{} section present in configuration
in init_module handler we now do the same in init_conf handler.  This
allows master process to detect incorrect configuration early and
reject it.

14 years agoDon't silently ignore the last line of configuration file that
Ruslan Ermilov [Wed, 18 Apr 2012 13:30:43 +0000 (13:30 +0000)]
Don't silently ignore the last line of configuration file that
consists solely of one unterminated token (inspired by #150).

14 years agoFixed ngx_readv_chain() to honor IOV_MAX (ticket #14).
Maxim Dounin [Tue, 17 Apr 2012 09:13:58 +0000 (09:13 +0000)]
Fixed ngx_readv_chain() to honor IOV_MAX (ticket #14).

Not using full chain passed is ok as consumers are expected to check
event's ready flag to determine if another call is needed, not the
returned size.

14 years agoIOV_MAX handling microoptimization.
Maxim Dounin [Tue, 17 Apr 2012 09:13:15 +0000 (09:13 +0000)]
IOV_MAX handling microoptimization.

We now stop on IOV_MAX iovec entries only if we are going to add new one,
i.e. next buffer can't be coalesced into last iovec.

This also fixes incorrect checks for trailer creation on FreeBSD and
Mac OS X, header.nelts was checked instead of trailer.nelts.

14 years agoFixed loop in ngx_writev_chain() and ngx_solaris_sendfilev_chain().
Maxim Dounin [Tue, 17 Apr 2012 09:10:50 +0000 (09:10 +0000)]
Fixed loop in ngx_writev_chain() and ngx_solaris_sendfilev_chain().

The "complete" flag wasn't cleared on loop iteration start, resulting in
broken behaviour if there were more than IOV_MAX buffers and first
iteration was fully completed (and hence the "complete" flag was set
to 1).

14 years agoFixed log->action after ssl handshake.
Maxim Dounin [Mon, 16 Apr 2012 13:05:20 +0000 (13:05 +0000)]
Fixed log->action after ssl handshake.

14 years agoFixed grammar in error messages.
Ruslan Ermilov [Thu, 12 Apr 2012 19:35:41 +0000 (19:35 +0000)]
Fixed grammar in error messages.

14 years agoVersion bump.
Maxim Dounin [Thu, 12 Apr 2012 16:34:59 +0000 (16:34 +0000)]
Version bump.

14 years agorelease-1.1.19 tag
Maxim Dounin [Thu, 12 Apr 2012 12:43:31 +0000 (12:43 +0000)]
release-1.1.19 tag

14 years agonginx-1.1.19-RELEASE release-1.1.19
Maxim Dounin [Thu, 12 Apr 2012 12:42:46 +0000 (12:42 +0000)]
nginx-1.1.19-RELEASE

14 years agoMp4: sanity checks cleanup.
Maxim Dounin [Thu, 12 Apr 2012 12:18:14 +0000 (12:18 +0000)]
Mp4: sanity checks cleanup.

14 years agoReduced the number of lines of code in ngx_inet_addr().
Ruslan Ermilov [Thu, 12 Apr 2012 10:20:33 +0000 (10:20 +0000)]
Reduced the number of lines of code in ngx_inet_addr().

14 years agoFixed buffer overflow when long URI is processed by "try_files" in
Ruslan Ermilov [Thu, 12 Apr 2012 09:19:14 +0000 (09:19 +0000)]
Fixed buffer overflow when long URI is processed by "try_files" in
regex location with "alias" (fixes ticket #135).

14 years agoImproved readability of the code that produces bitmask from prefix.
Ruslan Ermilov [Wed, 11 Apr 2012 17:18:15 +0000 (17:18 +0000)]
Improved readability of the code that produces bitmask from prefix.
In collaboration with Maxim Dounin.

14 years agoFixed directives inheritance.
Ruslan Ermilov [Wed, 11 Apr 2012 09:56:30 +0000 (09:56 +0000)]
Fixed directives inheritance.

14 years agoAccess module: fixed inheritance of allow/deny ipv6 rules.
Maxim Dounin [Tue, 10 Apr 2012 13:25:53 +0000 (13:25 +0000)]
Access module: fixed inheritance of allow/deny ipv6 rules.

Previous (incorrect) behaviour was to inherit ipv6 rules separately from
ipv4 ones.  Now all rules are either inherited (if there are no rules
defined at current level) or not (if there are any rules defined).

14 years agoFixed debug logging.
Igor Sysoev [Tue, 10 Apr 2012 11:28:59 +0000 (11:28 +0000)]
Fixed debug logging.

14 years agoFixed previous commit.
Igor Sysoev [Tue, 10 Apr 2012 11:27:43 +0000 (11:27 +0000)]
Fixed previous commit.

14 years agoFixed mp4 module seek.
Igor Sysoev [Tue, 10 Apr 2012 11:21:47 +0000 (11:21 +0000)]
Fixed mp4 module seek.

14 years agoFixed signed integer overflows in timer code (ticket #145).
Maxim Dounin [Fri, 6 Apr 2012 23:46:09 +0000 (23:46 +0000)]
Fixed signed integer overflows in timer code (ticket #145).

Integer overflow is undefined behaviour in C and this indeed caused
problems on Solaris/SPARC (at least in some cases).  Fix is to
subtract unsigned integers instead, and then cast result to a signed
one, which is implementation-defined behaviour and used to work.

Strictly speaking, we should compare (unsigned) result with the maximum
value of the corresponding signed integer type instead, this will be
defined behaviour.  This will require much more changes though, and
considered to be overkill for now.