]> git.kaiwu.me - nginx.git/log
nginx.git
10 years agoWin32: fixed build after cf3e75cfa951.
Ruslan Ermilov [Tue, 15 Mar 2016 12:15:30 +0000 (15:15 +0300)]
Win32: fixed build after cf3e75cfa951.

10 years agoWin32: fixed build after cf3e75cfa951.
Ruslan Ermilov [Tue, 15 Mar 2016 12:10:41 +0000 (15:10 +0300)]
Win32: fixed build after cf3e75cfa951.

10 years agoAdded variables support to server_tokens.
Ruslan Ermilov [Tue, 15 Mar 2016 10:36:19 +0000 (13:36 +0300)]
Added variables support to server_tokens.

It can now be set to "off" conditionally, e.g. using the map
directive.

An empty value will disable the emission of the Server: header
and the signature in error messages generated by nginx.

Any other value is treated as "on", meaning that full nginx
version is emitted in the Server: header and error messages
generated by nginx.

10 years agoFixed handling of EAGAIN with sendfile in threads.
Valentin Bartenev [Mon, 14 Mar 2016 19:42:35 +0000 (22:42 +0300)]
Fixed handling of EAGAIN with sendfile in threads.

10 years agoEvents: fixed error logging in devpoll.
Roman Arutyunyan [Mon, 14 Mar 2016 21:04:04 +0000 (00:04 +0300)]
Events: fixed error logging in devpoll.

10 years agoFixed compilation with -Wmissing-prototypes.
Sergey Kandaurov [Mon, 14 Mar 2016 16:23:23 +0000 (19:23 +0300)]
Fixed compilation with -Wmissing-prototypes.

10 years agoUpstream: avoid closing client connection in edge case.
Justin Li [Wed, 9 Mar 2016 03:31:55 +0000 (22:31 -0500)]
Upstream: avoid closing client connection in edge case.

If proxy_cache is enabled, and proxy_no_cache tests true, it was previously
possible for the client connection to be closed after a 304. The fix is to
recheck r->header_only after the final cacheability is determined, and end the
request if no longer cacheable.

Example configuration:

proxy_cache foo;
proxy_cache_bypass 1;
proxy_no_cache 1;

If a client sends If-None-Match, and the upstream server returns 200 with a
matching ETag, no body should be returned to the client. At the start of
ngx_http_upstream_send_response proxy_no_cache is not yet tested, thus cacheable
is still 1 and downstream_error is set.

However, by the time the downstream_error check is done in process_request,
proxy_no_cache has been tested and cacheable is set to 0. The client connection
is then closed, regardless of keepalive.

10 years agoUpstream: fixed "zero size buf" alerts with cache (ticket #918).
Maxim Dounin [Thu, 10 Mar 2016 18:58:03 +0000 (21:58 +0300)]
Upstream: fixed "zero size buf" alerts with cache (ticket #918).

If caching was used, "zero size buf in output" alerts might appear
in logs if a client prematurely closed connection.  Alerts appeared
in the following situation:

- writing to client returned an error, so event pipe
  drained all busy buffers leaving body output filters
  in an invalid state;

- when upstream response was fully received,
  ngx_http_upstream_finalize_request() tried to flush
  all pending data.

Fix is to avoid flushing body if p->downstream_error is set.

10 years agoConfigure: style.
Ruslan Ermilov [Thu, 10 Mar 2016 15:31:05 +0000 (18:31 +0300)]
Configure: style.

Generate Makefile with not so long lines.

10 years agoDynamic modules: do not overwrite old modules on install.
Maxim Dounin [Thu, 10 Mar 2016 13:50:13 +0000 (16:50 +0300)]
Dynamic modules: do not overwrite old modules on install.

Just using "cp" is incorrect, as it will overwrite old files
possibly used by OS, leading to unexpected effects.  Changed
to "mv + cp", much like used for the main binary.

10 years agoConfigure: style.
Ruslan Ermilov [Thu, 10 Mar 2016 07:43:00 +0000 (10:43 +0300)]
Configure: style.

Removed extraneous braces around shell variables.

10 years agoCopy filter: fixed sendfile aio handlers to set ctx->aio.
Maxim Dounin [Thu, 3 Mar 2016 18:14:19 +0000 (21:14 +0300)]
Copy filter: fixed sendfile aio handlers to set ctx->aio.

Sendfile handlers (aio preload and thread handler) are called within
ctx->output_filter() in ngx_output_chain(), and hence ctx->aio cannot
be set directly in ngx_output_chain().  Meanwhile, it must be set to
make sure loop within ngx_output_chain() will be properly terminated.

There are no known cases that trigger the problem, though in theory
something like aio + sub filter (something that needs body in memory,
and can also free some memory buffers) + sendfile can result in
"task already active" and "second aio post" alerts.

The fix is to set ctx->aio in ngx_http_copy_aio_sendfile_preload()
and ngx_http_copy_thread_handler().

For consistency, ctx->aio is no longer set explicitly in
ngx_output_chain_copy_buf(), as it's now done in
ngx_http_copy_thread_handler().

10 years agoFixed sendfile in threads (or with aio preload) and subrequests.
Maxim Dounin [Thu, 3 Mar 2016 18:14:12 +0000 (21:14 +0300)]
Fixed sendfile in threads (or with aio preload) and subrequests.

If sendfile in threads is used, it is possible that multiple
subrequests will trigger multiple ngx_linux_sendfile_thread() calls,
as operations are only serialized in output chain based on r->aio,
that is, on subrequest level.

This resulted in "task #N already active" alerts, in particular, when
running proxy_store.t with "aio threads; sendfile on;".

Fix is to tolerate duplicate calls, with an additional safety check
that the file is the same as previously used.

The same problem also affects "aio on; sendfile on;" on FreeBSD
(previously known as "aio sendfile;"), where aio->preload_handler()
could be called multiple times due to similar reasons, resulting in
"second aio post" alerts.  Fix is the same as well.

It is also believed that similar problems can arise if a filter
calls the next body filter multiple times for some reason.  These are
mostly theoretical though.

10 years agoIntroduced the ngx_chain_to_iovec() function.
Valentin Bartenev [Thu, 3 Mar 2016 15:41:05 +0000 (18:41 +0300)]
Introduced the ngx_chain_to_iovec() function.

It's similar to ngx_output_chain_to_iovec() and uses only preallocated memory.

10 years agoRequest body: moved handling of the last part in the save filter.
Valentin Bartenev [Tue, 1 Mar 2016 12:18:07 +0000 (15:18 +0300)]
Request body: moved handling of the last part in the save filter.

No functional changes.

10 years agoDynamic modules: perl.
Ruslan Ermilov [Fri, 26 Feb 2016 11:27:04 +0000 (14:27 +0300)]
Dynamic modules: perl.

10 years agoDynamic modules: expose the "modules" target.
Ruslan Ermilov [Mon, 29 Feb 2016 15:52:33 +0000 (18:52 +0300)]
Dynamic modules: expose the "modules" target.

10 years agoDynamic modules: removed unnecessary initialization.
Ruslan Ermilov [Thu, 25 Feb 2016 13:29:51 +0000 (16:29 +0300)]
Dynamic modules: removed unnecessary initialization.

It became unnecessary after 85dea406e18f.

10 years agoDynamic modules: make sure to call config.make for dynamic addons.
Ruslan Ermilov [Thu, 25 Feb 2016 12:22:05 +0000 (15:22 +0300)]
Dynamic modules: make sure to call config.make for dynamic addons.

10 years agoVersion bump.
Ruslan Ermilov [Thu, 25 Feb 2016 13:28:42 +0000 (16:28 +0300)]
Version bump.

10 years agorelease-1.9.12 tag
Maxim Dounin [Wed, 24 Feb 2016 14:53:23 +0000 (17:53 +0300)]
release-1.9.12 tag

10 years agonginx-1.9.12-RELEASE release-1.9.12
Maxim Dounin [Wed, 24 Feb 2016 14:53:22 +0000 (17:53 +0300)]
nginx-1.9.12-RELEASE

10 years agoHTTP/2: implemented per request timeouts (closes #626).
Valentin Bartenev [Wed, 24 Feb 2016 12:58:07 +0000 (15:58 +0300)]
HTTP/2: implemented per request timeouts (closes #626).

Previously, there were only three timeouts used globally for the whole HTTP/2
connection:

 1. Idle timeout for inactivity when there are no streams in processing
    (the "http2_idle_timeout" directive);

 2. Receive timeout for incomplete frames when there are no streams in
    processing (the "http2_recv_timeout" directive);

 3. Send timeout when there are frames waiting in the output queue
    (the "send_timeout" directive on a server level).

Reaching one of these timeouts leads to HTTP/2 connection close.

This left a number of scenarios when a connection can get stuck without any
processing and timeouts:

 1. A client has sent the headers block partially so nginx starts processing
    a new stream but cannot continue without the rest of HEADERS and/or
    CONTINUATION frames;

 2. When nginx waits for the request body;

 3. All streams are stuck on exhausted connection or stream windows.

The first idea that was rejected was to detect when the whole connection
gets stuck because of these situations and set the global receive timeout.
The disadvantage of such approach would be inconsistent behaviour in some
typical use cases.  For example, if a user never replies to the browser's
question about where to save the downloaded file, the stream will be
eventually closed by a timeout.  On the other hand, this will not happen
if there's some activity in other concurrent streams.

Now almost all the request timeouts work like in HTTP/1.x connections, so
the "client_header_timeout", "client_body_timeout", and "send_timeout" are
respected.  These timeouts close the request.

The global timeouts work as before.

Previously, the c->write->delayed flag was abused to avoid setting timeouts on
stream events.  Now, the "active" and "ready" flags are manipulated instead to
control the processing of individual streams.

10 years agoHTTP/2: always use temporary pool for processing headers.
Valentin Bartenev [Wed, 24 Feb 2016 13:05:47 +0000 (16:05 +0300)]
HTTP/2: always use temporary pool for processing headers.

This is required for implementing per request timeouts.

Previously, the temporary pool was used only during skipping of
headers and the request pool was used otherwise.  That required
switching of pools if the request was closed while parsing.

It wasn't a problem since the request could be closed only after
the validation of the fully parsed header.  With the per request
timeouts, the request can be closed at any moment, and switching
of pools in the middle of parsing header name or value becomes a
problem.

To overcome this, the temporary pool is now always created and
used.  Special checks are added to keep it when either the stream
is being processed or until header block is fully parsed.

10 years agoHTTP/2: cleaned up state while closing stream.
Valentin Bartenev [Wed, 24 Feb 2016 13:05:46 +0000 (16:05 +0300)]
HTTP/2: cleaned up state while closing stream.

Without this the state might keep pointing to already closed stream.

10 years agoFixed buffer over-read while logging invalid request headers.
Valentin Bartenev [Wed, 24 Feb 2016 13:01:23 +0000 (16:01 +0300)]
Fixed buffer over-read while logging invalid request headers.

Since 667aaf61a778 (1.1.17) the ngx_http_parse_header_line() function can return
NGX_HTTP_PARSE_INVALID_HEADER when a header contains NUL character.  In this
case the r->header_end pointer isn't properly initialized, but the log message
in ngx_http_process_request_headers() hasn't been adjusted.  It used the pointer
in size calculation, which might result in up to 2k buffer over-read.

Found with afl-fuzz.

10 years agoConfigure: added "build" target.
Maxim Dounin [Fri, 19 Feb 2016 15:13:54 +0000 (18:13 +0300)]
Configure: added "build" target.

The "build" target introduced to do all build-related tasks, and
it is now used in Makefile and in objs/Makefile as a dependency for
the "install" target.

In particular, this resolves problems as observed with dynamic modules
by people trying to do "make install" without calling "make" first.

10 years agoSSL: avoid calling SSL_shutdown() during handshake (ticket #901).
Maxim Dounin [Fri, 19 Feb 2016 14:27:30 +0000 (17:27 +0300)]
SSL: avoid calling SSL_shutdown() during handshake (ticket #901).

This fixes "called a function you should not call" and
"shutdown while in init" errors as observed with OpenSSL 1.0.2f
due to changes in how OpenSSL handles SSL_shutdown() during
SSL handshakes.

10 years agoSSL: fixed SSL_shutdown() comment.
Maxim Dounin [Fri, 19 Feb 2016 14:27:23 +0000 (17:27 +0300)]
SSL: fixed SSL_shutdown() comment.

10 years agoHeaders filter: fixed "add_header ... '' always".
Ruslan Ermilov [Thu, 18 Feb 2016 12:49:11 +0000 (15:49 +0300)]
Headers filter: fixed "add_header ... '' always".

The "always" parameter was ignored if the header value was empty.

10 years agoConfigure: skip building OpenSSL documentation to conserve time.
Sergey Kandaurov [Fri, 19 Feb 2016 10:31:55 +0000 (13:31 +0300)]
Configure: skip building OpenSSL documentation to conserve time.

The install_sw target first appeared in OpenSSL 0.9.7e and is documented since
OpenSSL 1.0.0 as the way to install the OpenSSL software without documentation.

10 years agoConfigure: fixed static nginx build with OpenSSL (ticket #903).
Ruslan Ermilov [Thu, 18 Feb 2016 08:39:57 +0000 (11:39 +0300)]
Configure: fixed static nginx build with OpenSSL (ticket #903).

Before 7142b04337d6, it was possible to build the OpenSSL library
along with nginx, and link nginx statically with this library
(--with-openssl=DIR --with-ld-opt=-static --with-http_ssl_module).
This was broken on Linux by not adding -ldl after -lcrypto.

The fix also makes it possible to link nginx statically on Linux
with the system OpenSSL library, which never worked before.

10 years agoCore: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov [Thu, 18 Feb 2016 10:58:49 +0000 (13:58 +0300)]
Core: added support for more than 64 CPUs in worker_cpu_affinity.

10 years agoHTTP/2: added debug logging of response headers.
Valentin Bartenev [Tue, 16 Feb 2016 14:49:14 +0000 (17:49 +0300)]
HTTP/2: added debug logging of response headers.

Because of HPACK compression it's hard to see what headers are actually
sent by the server.

10 years agoHTTP/2: use local pointer instead of r->connection.
Valentin Bartenev [Tue, 16 Feb 2016 14:49:14 +0000 (17:49 +0300)]
HTTP/2: use local pointer instead of r->connection.

No functional changes.

10 years agoCore: improved logging on invalid NGINX variable (ticket #900).
Maxim Dounin [Mon, 15 Feb 2016 14:41:52 +0000 (17:41 +0300)]
Core: improved logging on invalid NGINX variable (ticket #900).

10 years agoUpdated OpenSSL used for win32 builds.
Maxim Dounin [Sat, 13 Feb 2016 04:28:14 +0000 (07:28 +0300)]
Updated OpenSSL used for win32 builds.

10 years agoWin32: simplified and improved handling of MSVC versions.
Maxim Dounin [Sat, 13 Feb 2016 03:47:34 +0000 (06:47 +0300)]
Win32: simplified and improved handling of MSVC versions.

Now we always set NGX_CC_NAME to "msvc", and additionally test compiler
version as reported by "cl" in auto/cc/msvc (the same version is also
available via the _MSC_VER define).  In particular, this approach allows
to properly check for C99 variadic macros support, which previously was
not used with MSVC versions not explicitly recognized.

Now unneeded wildcards in NGX_CC_NAME tests for msvc removed accordingly,
as well as unused wildcards for owc and icc.

10 years agoHTTP/2: fixed undefined behavior in ngx_http_v2_huff_encode().
Valentin Bartenev [Fri, 12 Feb 2016 13:36:20 +0000 (16:36 +0300)]
HTTP/2: fixed undefined behavior in ngx_http_v2_huff_encode().

When the "pending" value is zero, the "buf" will be right shifted
by the width of its type, which results in undefined behavior.

Found by Coverity (CID 1352150).

10 years agoHTTP/2: implemented HPACK Huffman encoding for response headers.
Valentin Bartenev [Thu, 11 Feb 2016 12:35:36 +0000 (15:35 +0300)]
HTTP/2: implemented HPACK Huffman encoding for response headers.

This reduces the size of headers by over 30% on average.

Based on the patch by Vlad Krasnov:
http://mailman.nginx.org/pipermail/nginx-devel/2015-December/007682.html

10 years agoDynamic modules: fixed a version mismatch message (ticket #898).
Ruslan Ermilov [Thu, 11 Feb 2016 15:46:46 +0000 (18:46 +0300)]
Dynamic modules: fixed a version mismatch message (ticket #898).

Based on a patch by Takashi Takizawa.

10 years agoStream: initialize variable right before using it.
Roman Arutyunyan [Thu, 11 Feb 2016 11:20:26 +0000 (14:20 +0300)]
Stream: initialize variable right before using it.

10 years agoStream: removed useless typedef.
Roman Arutyunyan [Thu, 11 Feb 2016 11:20:22 +0000 (14:20 +0300)]
Stream: removed useless typedef.

10 years agoDynamic modules: added auth_basic module libs via ngx_module_libs=.
Ruslan Ermilov [Wed, 10 Feb 2016 08:36:25 +0000 (11:36 +0300)]
Dynamic modules: added auth_basic module libs via ngx_module_libs=.

10 years agoCore: ngx_module_t compatibility with C++.
Piotr Sikora [Wed, 10 Feb 2016 00:31:26 +0000 (16:31 -0800)]
Core: ngx_module_t compatibility with C++.

Changes to NGX_MODULE_V1 and ngx_module_t in 85dea406e18f (1.9.11)
broke all modules written in C++, because ISO C++11 does not allow
conversion from string literal to char *.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
10 years agoVersion bump.
Maxim Dounin [Wed, 10 Feb 2016 03:23:34 +0000 (06:23 +0300)]
Version bump.

10 years agorelease-1.9.11 tag
Maxim Dounin [Tue, 9 Feb 2016 14:11:57 +0000 (17:11 +0300)]
release-1.9.11 tag

10 years agonginx-1.9.11-RELEASE release-1.9.11
Maxim Dounin [Tue, 9 Feb 2016 14:11:56 +0000 (17:11 +0300)]
nginx-1.9.11-RELEASE

10 years agoDynamic modules: NGX_STREAM define removed.
Maxim Dounin [Mon, 8 Feb 2016 15:02:04 +0000 (18:02 +0300)]
Dynamic modules: NGX_STREAM define removed.

It's not used and contradicts the idea of dynamic loading.

10 years agoDynamic modules: added dlsym() to configure test.
Valentin Bartenev [Fri, 5 Feb 2016 18:48:25 +0000 (21:48 +0300)]
Dynamic modules: added dlsym() to configure test.

It appears that AddressSanitizer in GCC 5 intercepts dlopen() and dlclose()
but not dlsym().

10 years agoDynamic modules: fixed a copy-n-paste error.
Ruslan Ermilov [Fri, 5 Feb 2016 11:02:54 +0000 (14:02 +0300)]
Dynamic modules: fixed a copy-n-paste error.

10 years agoDynamic modules.
Maxim Dounin [Thu, 4 Feb 2016 17:25:29 +0000 (20:25 +0300)]
Dynamic modules.

The auto/module script is extended to understand ngx_module_link=DYNAMIC.
When set, it links the module as a shared object rather than statically
into nginx binary.  The module can later be loaded using the "load_module"
directive.

New auto/module parameter ngx_module_order allows to define module loading
order in complex cases.  By default the order is set based on ngx_module_type.

3rd party modules can be compiled dynamically using the --add-dynamic-module
configure option, which will preset ngx_module_link to "DYNAMIC" before
calling the module config script.

Win32 support is rudimentary, and only works when using MinGW gcc (which
is able to handle exports/imports automatically).

In collaboration with Ruslan Ermilov.

10 years agoDynamic modules: auto/module script.
Maxim Dounin [Thu, 4 Feb 2016 15:30:21 +0000 (18:30 +0300)]
Dynamic modules: auto/module script.

This script simplifies configuration of additional modules,
including 3rd party ones.  The script is extensible, and
will be used to introduce dynamic linking of modules in upcoming
changes.

3rd party module config scripts are called with ngx_module_link
preset to "ADDON" - this allows config scripts to call auto/module
without ngx_module_link explicitly defined, as well as testing if
new interface is in place if compatibility with older nginx versions
is desired.

In collaboration with Ruslan Ermilov.

10 years agoDynamic modules: introduced HTTP_INIT_FILTER_MODULES.
Maxim Dounin [Thu, 4 Feb 2016 15:30:21 +0000 (18:30 +0300)]
Dynamic modules: introduced HTTP_INIT_FILTER_MODULES.

Additionally, HTTP_HEADERS_FILTER_MODULE now added to HTTP_FILTER_MODULES.
This avoids explict use of modules at the later stages, now only module
lists are used.  This will be needed in later patches.

10 years agoDynamic modules: dlopen() support.
Maxim Dounin [Thu, 4 Feb 2016 15:30:21 +0000 (18:30 +0300)]
Dynamic modules: dlopen() support.

10 years agoDynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin [Thu, 4 Feb 2016 15:30:21 +0000 (18:30 +0300)]
Dynamic modules: changed ngx_modules to cycle->modules.

10 years agoDynamic modules: moved module-related stuff to separate files.
Maxim Dounin [Thu, 4 Feb 2016 15:30:21 +0000 (18:30 +0300)]
Dynamic modules: moved module-related stuff to separate files.

10 years agoHTTP/2: fixed possible buffer overrun (ticket #893).
Valentin Bartenev [Thu, 4 Feb 2016 15:01:04 +0000 (18:01 +0300)]
HTTP/2: fixed possible buffer overrun (ticket #893).

Due to greater priority of the unary plus operator over the ternary operator
the expression didn't work as expected.  That might result in one byte less
allocation than needed for the HEADERS frame buffer.

10 years agoHTTP/2: fixed padding handling in HEADERS frame with CONTINUATION.
Valentin Bartenev [Tue, 2 Feb 2016 13:33:55 +0000 (16:33 +0300)]
HTTP/2: fixed padding handling in HEADERS frame with CONTINUATION.

10 years agoHTTP/2: fixed request length accounting.
Valentin Bartenev [Tue, 2 Feb 2016 13:33:55 +0000 (16:33 +0300)]
HTTP/2: fixed request length accounting.

Now it includes not only the received body size,
but the size of headers block as well.

10 years agoHTTP/2: fixed excessive memory allocation for pool cleanup.
Valentin Bartenev [Tue, 2 Feb 2016 13:33:55 +0000 (16:33 +0300)]
HTTP/2: fixed excessive memory allocation for pool cleanup.

10 years agoHTTP/2: removed unused field from ngx_http_v2_stream_t.
Valentin Bartenev [Tue, 2 Feb 2016 13:33:55 +0000 (16:33 +0300)]
HTTP/2: removed unused field from ngx_http_v2_stream_t.

10 years agoResolver: style.
Ruslan Ermilov [Thu, 17 Dec 2015 14:30:22 +0000 (17:30 +0300)]
Resolver: style.

Use the original query name in error and debug messages when
processing PTR responses.

10 years agoResolver: improved PTR response processing.
Ruslan Ermilov [Thu, 17 Dec 2015 14:21:16 +0000 (17:21 +0300)]
Resolver: improved PTR response processing.

The previous code only parsed the first answer, without checking its
type, and required a compressed RR name.

The new code checks the RR type, supports responses with multiple
answers, and doesn't require the RR name to be compressed.

This has a side effect in limited support of CNAME.  If a response
includes both CNAME and PTR RRs, like when recursion is enabled on
the server, PTR RR is handled.

Full CNAME support in PTR response is not implemented in this change.

10 years agoResolver: style.
Ruslan Ermilov [Thu, 17 Dec 2015 14:21:12 +0000 (17:21 +0300)]
Resolver: style.

Renamed argument in ngx_resolver_process_a() for consistency.

10 years agoResolver: free TCP buffers on resolver cleanup.
Roman Arutyunyan [Tue, 2 Feb 2016 10:42:55 +0000 (13:42 +0300)]
Resolver: free TCP buffers on resolver cleanup.

10 years agoResolver: fixed possible resource leak introduced in 5a16d40c63de.
Ruslan Ermilov [Tue, 2 Feb 2016 08:35:19 +0000 (11:35 +0300)]
Resolver: fixed possible resource leak introduced in 5a16d40c63de.

Found by Coverity (CID 1351175).

10 years agoResolver: TCP support.
Roman Arutyunyan [Thu, 28 Jan 2016 12:28:20 +0000 (15:28 +0300)]
Resolver: TCP support.

Resend DNS query over TCP once UDP response came truncated.

10 years agoResolver: per-request DNS server balancer.
Roman Arutyunyan [Thu, 28 Jan 2016 12:28:20 +0000 (15:28 +0300)]
Resolver: per-request DNS server balancer.

Previously, a global server balancer was used to assign the next DNS server to
send a query to.  That could lead to a non-uniform distribution of servers per
request.  A request could be assigned to the same dead server several times in a
row and wait longer for a valid server or even time out without being processed.

Now each query is sent to all servers sequentially in a circle until a
response is received or timeout expires.  Initial server for each request is
still globally balanced.

10 years agoResolver: renamed UDP-specific structures, fields and variables.
Roman Arutyunyan [Thu, 28 Jan 2016 12:28:20 +0000 (15:28 +0300)]
Resolver: renamed UDP-specific structures, fields and variables.

They will be used for TCP connections as well.

10 years agoResolver: removed unused field from ngx_resolver_ctx_t.
Roman Arutyunyan [Thu, 28 Jan 2016 12:28:19 +0000 (15:28 +0300)]
Resolver: removed unused field from ngx_resolver_ctx_t.

10 years agoVersion bump.
Roman Arutyunyan [Thu, 28 Jan 2016 12:25:58 +0000 (15:25 +0300)]
Version bump.

10 years agorelease-1.9.10 tag
Maxim Dounin [Tue, 26 Jan 2016 14:27:41 +0000 (17:27 +0300)]
release-1.9.10 tag

10 years agonginx-1.9.10-RELEASE release-1.9.10
Maxim Dounin [Tue, 26 Jan 2016 14:27:40 +0000 (17:27 +0300)]
nginx-1.9.10-RELEASE

10 years agoResolver: limited CNAME recursion.
Ruslan Ermilov [Tue, 26 Jan 2016 13:47:14 +0000 (16:47 +0300)]
Resolver: limited CNAME recursion.

Previously, the recursion was only limited for cached responses.

10 years agoResolver: fixed use-after-free memory accesses with CNAME.
Roman Arutyunyan [Tue, 26 Jan 2016 13:46:59 +0000 (16:46 +0300)]
Resolver: fixed use-after-free memory accesses with CNAME.

When several requests were waiting for a response, then after getting
a CNAME response only the last request's context had the name updated.
Contexts of other requests had the wrong name.  This name was used by
ngx_resolve_name_done() to find the node to remove the request context
from.  When the name was wrong, the request could not be properly
cancelled, its context was freed but stayed linked to the node's waiting
list.  This happened e.g. when the first request was aborted or timed
out before the resolving completed.  When it completed, this triggered
a use-after-free memory access by calling ctx->handler of already freed
request context.  The bug manifests itself by
"could not cancel <name> resolving" alerts in error_log.

When a request was responded with a CNAME, the request context kept
the pointer to the original node's rn->u.cname.  If the original node
expired before the resolving timed out or completed with an error,
this would trigger a use-after-free memory access via ctx->name in
ctx->handler().

The fix is to keep ctx->name unmodified.  The name from context
is no longer used by ngx_resolve_name_done().  Instead, we now keep
the pointer to resolver node to which this request is linked.
Keeping the original name intact also improves logging.

10 years agoResolver: changed the ngx_resolver_create_*_query() arguments.
Roman Arutyunyan [Tue, 26 Jan 2016 13:46:48 +0000 (16:46 +0300)]
Resolver: changed the ngx_resolver_create_*_query() arguments.

No functional changes.

This is needed by the following change.

10 years agoResolver: fixed CNAME processing for several requests.
Ruslan Ermilov [Tue, 26 Jan 2016 13:46:38 +0000 (16:46 +0300)]
Resolver: fixed CNAME processing for several requests.

When several requests were waiting for a response, then after getting
a CNAME response only the last request was properly processed, while
others were left waiting.

10 years agoResolver: fixed crashes in timeout handler.
Ruslan Ermilov [Tue, 26 Jan 2016 13:46:31 +0000 (16:46 +0300)]
Resolver: fixed crashes in timeout handler.

If one or more requests were waiting for a response, then after
getting a CNAME response, the timeout event on the first request
remained active, pointing to the wrong node with an empty
rn->waiting list, and that could cause either null pointer
dereference or use-after-free memory access if this timeout
expired.

If several requests were waiting for a response, and the first
request terminated (e.g., due to client closing a connection),
other requests were left without a timeout and could potentially
wait indefinitely.

This is fixed by introducing per-request independent timeouts.
This change also reverts 954867a2f0a6 and 5004210e8c78.

10 years agoResolver: fixed possible segmentation fault on DNS format error.
Roman Arutyunyan [Tue, 26 Jan 2016 13:46:18 +0000 (16:46 +0300)]
Resolver: fixed possible segmentation fault on DNS format error.

10 years agoRequest body: removed surplus assigment, no functional changes.
Valentin Bartenev [Tue, 12 Jan 2016 16:19:07 +0000 (19:19 +0300)]
Request body: removed surplus assigment, no functional changes.

Setting rb->bufs to NULL is surplus after ngx_http_write_request_body()
has returned NGX_OK.

10 years agoCore: worker_cpu_affinity auto.
Maxim Dounin [Mon, 11 Jan 2016 16:23:17 +0000 (19:23 +0300)]
Core: worker_cpu_affinity auto.

If enabled, workers are bound to available CPUs, each worker to once CPU
in order.  If there are more workers than available CPUs, remaining are
bound in a loop, starting again from the first available CPU.

The optional mask parameter defines which CPUs are available for automatic
binding.

In collaboration with Vladimir Homutov.

10 years agoUpstream: fixed changing method on X-Accel-Redirect.
Maxim Dounin [Mon, 11 Jan 2016 16:08:12 +0000 (19:08 +0300)]
Upstream: fixed changing method on X-Accel-Redirect.

Previously, only r->method was changed, resulting in handling of a request
as GET within nginx itself, but not in requests to proxied servers.

See http://mailman.nginx.org/pipermail/nginx/2015-December/049518.html.

10 years agoYear 2016.
Ruslan Ermilov [Mon, 11 Jan 2016 07:53:49 +0000 (10:53 +0300)]
Year 2016.

10 years agoUpstream: don't keep connections on early responses (ticket #669).
Maxim Dounin [Thu, 17 Dec 2015 13:39:15 +0000 (16:39 +0300)]
Upstream: don't keep connections on early responses (ticket #669).

10 years agoFixed PROXY protocol on IPv6 sockets (ticket #858).
Maxim Dounin [Thu, 17 Dec 2015 13:39:02 +0000 (16:39 +0300)]
Fixed PROXY protocol on IPv6 sockets (ticket #858).

10 years agoVersion bump.
Maxim Dounin [Thu, 17 Dec 2015 13:38:51 +0000 (16:38 +0300)]
Version bump.

10 years agoFixed a typo.
Ruslan Ermilov [Sat, 12 Dec 2015 07:32:58 +0000 (10:32 +0300)]
Fixed a typo.

10 years agorelease-1.9.9 tag
Maxim Dounin [Wed, 9 Dec 2015 14:47:21 +0000 (17:47 +0300)]
release-1.9.9 tag

10 years agonginx-1.9.9-RELEASE release-1.9.9
Maxim Dounin [Wed, 9 Dec 2015 14:47:20 +0000 (17:47 +0300)]
nginx-1.9.9-RELEASE

10 years agoFixed fastcgi_pass with UNIX socket and variables (ticket #855).
Ruslan Ermilov [Wed, 9 Dec 2015 13:26:59 +0000 (16:26 +0300)]
Fixed fastcgi_pass with UNIX socket and variables (ticket #855).

This was broken in a93345ee8f52 (1.9.8).

10 years agoVersion bump.
Ruslan Ermilov [Wed, 9 Dec 2015 11:41:16 +0000 (14:41 +0300)]
Version bump.

10 years agorelease-1.9.8 tag
Maxim Dounin [Tue, 8 Dec 2015 15:16:52 +0000 (18:16 +0300)]
release-1.9.8 tag

10 years agonginx-1.9.8-RELEASE release-1.9.8
Maxim Dounin [Tue, 8 Dec 2015 15:16:51 +0000 (18:16 +0300)]
nginx-1.9.8-RELEASE

10 years agoSlice filter: terminate first slice with last_in_chain flag.
Roman Arutyunyan [Tue, 8 Dec 2015 14:39:56 +0000 (17:39 +0300)]
Slice filter: terminate first slice with last_in_chain flag.

This flag makes sub filter flush buffered data and optimizes allocation in copy
filter.

10 years agoSlice filter: never run subrequests when main request is buffered.
Roman Arutyunyan [Tue, 8 Dec 2015 14:39:56 +0000 (17:39 +0300)]
Slice filter: never run subrequests when main request is buffered.

With main request buffered, it's possible, that a slice subrequest will send
output before it.  For example, while main request is waiting for aio read to
complete, a slice subrequest can start an aio operation as well.  The order
in which aio callbacks are called is undetermined.

10 years agoSSL: fixed possible segfault on renegotiation (ticket #845).
Sergey Kandaurov [Tue, 8 Dec 2015 13:59:43 +0000 (16:59 +0300)]
SSL: fixed possible segfault on renegotiation (ticket #845).

Skip SSL_CTX_set_tlsext_servername_callback in case of renegotiation.
Do nothing in SNI callback as in this case it will be supplied with
request in c->data which isn't expected and doesn't work this way.

This was broken by b40af2fd1c16 (1.9.6) with OpenSSL master branch and LibreSSL.

10 years agoUpdated OpenSSL and PCRE used for win32 builds.
Maxim Dounin [Mon, 7 Dec 2015 17:09:34 +0000 (20:09 +0300)]
Updated OpenSSL and PCRE used for win32 builds.

10 years agoAdded slice module to win32 builds.
Maxim Dounin [Mon, 7 Dec 2015 17:08:13 +0000 (20:08 +0300)]
Added slice module to win32 builds.

10 years agoSlice filter.
Roman Arutyunyan [Mon, 7 Dec 2015 13:30:48 +0000 (16:30 +0300)]
Slice filter.

Splits a request into subrequests, each providing a specific range of response.
The variable "$slice_range" must be used to set subrequest range and proper
cache key.  The directive "slice" sets slice size.

The following example splits requests into 1-megabyte cacheable subrequests.

server {
    listen 8000;

    location / {
        slice 1m;

        proxy_cache cache;
        proxy_cache_key $uri$is_args$args$slice_range;
        proxy_set_header Range $slice_range;
        proxy_cache_valid 200 206 1h;
        proxy_pass http://127.0.0.1:9000;
    }
}