]> git.kaiwu.me - nginx.git/log
nginx.git
10 years agoFixed --test-build-*.
Ruslan Ermilov [Mon, 28 Mar 2016 16:29:18 +0000 (19:29 +0300)]
Fixed --test-build-*.

Fixes various aspects of --test-build-devpoll, --test-build-eventport, and
--test-build-epoll.

In particular, if --test-build-devpoll was used on Linux, then "devpoll"
event method would be preferred over "epoll".  Also, wrong definitions of
event macros were chosen.

10 years agoSub filter: fixed allocation alignment.
Roman Arutyunyan [Mon, 28 Mar 2016 10:35:25 +0000 (13:35 +0300)]
Sub filter: fixed allocation alignment.

10 years agoCore: allow strings without null-termination in ngx_parse_url().
Piotr Sikora [Sat, 27 Feb 2016 01:30:27 +0000 (17:30 -0800)]
Core: allow strings without null-termination in ngx_parse_url().

This fixes buffer over-read while using variables in the "proxy_pass",
"fastcgi_pass", "scgi_pass", and "uwsgi_pass" directives, where result
of string evaluation isn't null-terminated.

Found with MemorySanitizer.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
10 years agoFixed socket inheritance on reload and binary upgrade.
Roman Arutyunyan [Fri, 25 Mar 2016 11:10:38 +0000 (14:10 +0300)]
Fixed socket inheritance on reload and binary upgrade.

On nginx reload or binary upgrade, an attempt is made to inherit listen sockets
from the previous configuration.  Previously, no check for socket type was made
and the inherited socket could have the wrong type.  On binary upgrade, socket
type was not detected at all.  Wrong socket type could lead to errors on that
socket due to different logic and unsupported syscalls.  For example, a UDP
socket, inherited as TCP, lead to the following error after arrival of a
datagram: "accept() failed (102: Operation not supported on socket)".

10 years agoStream: additional logging for UDP.
Vladimir Homutov [Fri, 18 Mar 2016 16:53:22 +0000 (19:53 +0300)]
Stream: additional logging for UDP.

10 years agoWin32: fixed build after 384154fc634f.
Dmitry Volyntsev [Wed, 23 Mar 2016 15:34:05 +0000 (18:34 +0300)]
Win32: fixed build after 384154fc634f.

10 years agoStream: detect port absence in proxy_pass with IP literal.
Roman Arutyunyan [Wed, 23 Mar 2016 14:45:15 +0000 (17:45 +0300)]
Stream: detect port absence in proxy_pass with IP literal.

This is a clone of http commit 26c127bab5ef.

10 years agoResolver: added support for SRV records.
Dmitry Volyntsev [Wed, 23 Mar 2016 14:44:36 +0000 (17:44 +0300)]
Resolver: added support for SRV records.

10 years agoResolver: do not enable resolve timer if provided timeout is zero.
Dmitry Volyntsev [Wed, 23 Mar 2016 14:44:36 +0000 (17:44 +0300)]
Resolver: do not enable resolve timer if provided timeout is zero.

10 years agoResolver: introduced valid field in resolver responses.
Dmitry Volyntsev [Wed, 23 Mar 2016 14:44:36 +0000 (17:44 +0300)]
Resolver: introduced valid field in resolver responses.

It hints the amount of time a response could be considered
as valid.

10 years agoCore: introduced the NGX_DEBUG_PALLOC macro.
Valentin Bartenev [Wed, 23 Mar 2016 14:44:04 +0000 (17:44 +0300)]
Core: introduced the NGX_DEBUG_PALLOC macro.

It allows to turn off accumulation of small pool allocations into a big
preallocated chunk of memory.  This is useful for debugging memory access
with sanitizer, since such accumulation can cover buffer overruns from
being detected.

10 years agoCore: use ngx_palloc_small() to allocate ngx_pool_large_t.
Valentin Bartenev [Wed, 23 Mar 2016 14:44:04 +0000 (17:44 +0300)]
Core: use ngx_palloc_small() to allocate ngx_pool_large_t.

This structure cannot be allocated as a large block anyway, otherwise that will
result in infinite recursion, since each large allocation requires to allocate
another ngx_pool_large_t.

The room for the structure is guaranteed by the NGX_MIN_POOL_SIZE constant.

10 years agoCore: introduced the ngx_palloc_small() function.
Valentin Bartenev [Wed, 23 Mar 2016 14:44:04 +0000 (17:44 +0300)]
Core: introduced the ngx_palloc_small() function.

It deduplicates some code for allocations from memory pool.
No functional changes.

10 years agoCore: moved logging before freeing large blocks of pool.
Valentin Bartenev [Wed, 23 Mar 2016 14:44:04 +0000 (17:44 +0300)]
Core: moved logging before freeing large blocks of pool.

This fixes use-after-free memory access with enabled debug log
when pool->log is allocated as a large block.

10 years agoBacked out server_tokens changes.
Maxim Dounin [Tue, 22 Mar 2016 13:58:38 +0000 (16:58 +0300)]
Backed out server_tokens changes.

Backed out changesets: cf3e75cfa9516b72414dfb4f602dc42035fee5076b96fd01.

10 years agoCache: fixed slots accounting error introduced in c9d680b00744.
Dmitry Volyntsev [Wed, 23 Mar 2016 11:16:31 +0000 (14:16 +0300)]
Cache: fixed slots accounting error introduced in c9d680b00744.

10 years agoReconsidered server_tokens with an empty value.
Ruslan Ermilov [Tue, 22 Mar 2016 12:52:28 +0000 (15:52 +0300)]
Reconsidered server_tokens with an empty value.

An empty value will be treated as "off".

10 years agoHTTP/2: improved debugging of sending control frames.
Valentin Bartenev [Mon, 21 Mar 2016 14:04:21 +0000 (17:04 +0300)]
HTTP/2: improved debugging of sending control frames.

10 years agoEvents: fixed test building with devpoll and eventport on Linux.
Sergey Kandaurov [Mon, 21 Mar 2016 09:36:36 +0000 (12:36 +0300)]
Events: fixed test building with devpoll and eventport on Linux.

Avoid POLLREMOVE and itimerspec redefinition.

10 years agoFix build with -Wmissing-prototypes.
Piotr Sikora [Fri, 18 Mar 2016 23:38:08 +0000 (16:38 -0700)]
Fix build with -Wmissing-prototypes.

Broken in 5eb4d7541107 (1.9.6), fix somehow missed in 3600bbfb43e3.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
10 years agoCache: added watermark to reduce IO load when keys_zone is full.
Dmitry Volyntsev [Fri, 18 Mar 2016 12:08:21 +0000 (15:08 +0300)]
Cache: added watermark to reduce IO load when keys_zone is full.

When a keys_zone is full then each next request to the cache is
penalized.  That is, the cache has to evict older files to get a
slot from the keys_zone synchronously.  The patch introduces new
behavior in this scenario.  Manager will try to maintain available
free slots in the keys_zone by cleaning old files in the background.

10 years agoCache: report error if slab allocator fails during cache loading.
Dmitry Volyntsev [Fri, 18 Mar 2016 11:27:30 +0000 (14:27 +0300)]
Cache: report error if slab allocator fails during cache loading.

10 years agoThreads: writing via threads pools in event pipe.
Maxim Dounin [Fri, 18 Mar 2016 03:44:49 +0000 (06:44 +0300)]
Threads: writing via threads pools in event pipe.

The "aio_write" directive is introduced, which enables use of aio
for writing.  Currently it is meaningful only with "aio threads".

Note that aio operations can be done by both event pipe and output
chain, so proper mapping between r->aio and p->aio is provided when
calling ngx_event_pipe() and in output filter.

In collaboration with Valentin Bartenev.

10 years agoThreads: offloading of temp files writing to thread pools.
Maxim Dounin [Fri, 18 Mar 2016 03:44:03 +0000 (06:44 +0300)]
Threads: offloading of temp files writing to thread pools.

The ngx_thread_write_chain_to_file() function introduced, which
uses ngx_file_t thread_handler, thread_ctx and thread_task fields.
The task context structure (ngx_thread_file_ctx_t) is the same for
both reading and writing, and can be safely shared as long as
operations are serialized.

The task->handler field is now always set (and not only when task is
allocated), as the same task can be used with different handlers.

The thread_write flag is introduced in the ngx_temp_file_t structure
to explicitly enable use of ngx_thread_write_chain_to_file() in
ngx_write_chain_to_temp_file() when supported by caller.

In collaboration with Valentin Bartenev.

10 years agoThreads: task pointer stored in ngx_file_t.
Maxim Dounin [Fri, 18 Mar 2016 03:43:52 +0000 (06:43 +0300)]
Threads: task pointer stored in ngx_file_t.

This simplifies the interface of the ngx_thread_read() function.

Additionally, most of the thread operations now explicitly set
file->thread_task, file->thread_handler and file->thread_ctx,
to facilitate use of thread operations in other places.

(Potential problems remain with sendfile in threads though - it uses
file->thread_handler as set in ngx_output_chain(), and it should not
be overwritten to an incompatible one.)

In collaboration with Valentin Bartenev.

10 years agoFixed timeouts with threaded sendfile() and subrequests.
Maxim Dounin [Fri, 18 Mar 2016 02:04:45 +0000 (05:04 +0300)]
Fixed timeouts with threaded sendfile() and subrequests.

If a write event happens after sendfile() but before we've got the
sendfile results in the main thread, this write event will be ignored.
And if no more events will happen, the connection will hang.

Removing the events works in the simple cases, but not always, as
in some cases events are added back by an unrelated code.  E.g.,
the upstream module adds write event in the ngx_http_upstream_init()
to track client aborts.

Fix is to use wev->complete instead.  It is now set to 0 before
a sendfile() task is posted, and it is set to 1 once a write event
happens.  If on completion of the sendfile() task wev->complete is 1,
we know that an event happened while we were executing sendfile(), and
the socket is still ready for writing even if sendfile() did not sent
all the data or returned EAGAIN.

10 years agoStyle.
Ruslan Ermilov [Wed, 16 Mar 2016 11:44:41 +0000 (14:44 +0300)]
Style.

10 years agoTruncation detection in sendfilev() on Solaris.
Maxim Dounin [Tue, 15 Mar 2016 15:26:59 +0000 (18:26 +0300)]
Truncation detection in sendfilev() on Solaris.

While sendfilev() is documented to return -1 with EINVAL set
if the file was truncated, at least Solaris 11 silently returns 0,
and this results in CPU hog.  Added a test to complain appropriately
if 0 is returned.

10 years agoTruncation detection in sendfile() on Linux.
Maxim Dounin [Tue, 15 Mar 2016 15:26:17 +0000 (18:26 +0300)]
Truncation detection in sendfile() on Linux.

This addresses connection hangs as observed in ticket #504, and
CPU hogs with "aio threads; sendfile on" as reported in the mailing list,
see http://mailman.nginx.org/pipermail/nginx-ru/2016-March/057638.html.

The alert is identical to one used on FreeBSD.

10 years agoStream: UDP proxy.
Roman Arutyunyan [Wed, 20 Jan 2016 16:52:12 +0000 (19:52 +0300)]
Stream: UDP proxy.

10 years agoStream: post first read events from client and upstream.
Roman Arutyunyan [Tue, 15 Mar 2016 12:55:23 +0000 (15:55 +0300)]
Stream: post first read events from client and upstream.

The main proxy function ngx_stream_proxy_process() can terminate the stream
session.  The code, following it, should check its return code to make sure the
session still exists.  This happens in client and upstream initialization
functions.  Swapping ngx_stream_proxy_process() call with the code, that
follows it, leaves the same problem vice versa.

In future ngx_stream_proxy_process() will call ngx_stream_proxy_next_upstream()
making it too complicated to know if stream session still exists after this
call.

Now ngx_stream_proxy_process() is called from posted event handlers in both
places with no code following it.  The posted event is automatically removed
once session is terminated.

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.