]> git.kaiwu.me - nginx.git/log
nginx.git
9 years agoHTTP/2: fixed saving preread buffer to temp file (ticket #1143).
Valentin Bartenev [Mon, 28 Nov 2016 16:19:21 +0000 (19:19 +0300)]
HTTP/2: fixed saving preread buffer to temp file (ticket #1143).

Previously, a request body bigger than "client_body_buffer_size" wasn't written
into a temporary file if it has been pre-read entirely.  The preread buffer
is freed after processing, thus subsequent use of it might result in sending
corrupted body or cause a segfault.

9 years agoHTTP/2: graceful shutdown of active connections (closes #1106).
Valentin Bartenev [Thu, 20 Oct 2016 13:15:03 +0000 (16:15 +0300)]
HTTP/2: graceful shutdown of active connections (closes #1106).

Previously, while shutting down gracefully, the HTTP/2 connections were
closed in transition to idle state after all active streams have been
processed.  That might never happen if the client continued opening new
streams.

Now, nginx sends GOAWAY to all HTTP/2 connections and ignores further
attempts to open new streams.  A worker process will quit as soon as
processing of already opened streams is finished.

9 years agoCore: sockaddr lengths now respected by ngx_cmp_sockaddr().
Maxim Dounin [Mon, 10 Oct 2016 13:15:41 +0000 (16:15 +0300)]
Core: sockaddr lengths now respected by ngx_cmp_sockaddr().

Linux can return AF_UNIX sockaddrs with partially filled sun_path,
resulting in spurious comparison failures and failed binary upgrades.
Added proper checking of the lengths provided.

Reported by Jan Seda,
http://mailman.nginx.org/pipermail/nginx-devel/2016-September/008832.html.

9 years agoAddition filter: set last_in_chain flag when clearing last_buf.
Roman Arutyunyan [Mon, 3 Oct 2016 18:03:27 +0000 (21:03 +0300)]
Addition filter: set last_in_chain flag when clearing last_buf.

When the last_buf flag is cleared for add_after_body to append more data from a
subrequest, other filters may still have buffered data, which should be flushed
at this point.  For example, the sub_filter may have a partial match buffered,
which will only be flushed after the subrequest is done, ending up with
interleaved data in output.

Setting last_in_chain instead of last_buf flushes the data and fixes the order
of output buffers.

9 years agoVersion bump.
Maxim Dounin [Tue, 31 Jan 2017 13:15:31 +0000 (16:15 +0300)]
Version bump.

9 years agorelease-1.10.2 tag
Maxim Dounin [Tue, 18 Oct 2016 15:03:13 +0000 (18:03 +0300)]
release-1.10.2 tag

9 years agonginx-1.10.2-RELEASE release-1.10.2
Maxim Dounin [Tue, 18 Oct 2016 15:03:12 +0000 (18:03 +0300)]
nginx-1.10.2-RELEASE

9 years agoSSL: default DH parameters compatible with OpenSSL 1.1.0.
Maxim Dounin [Tue, 18 Oct 2016 14:25:38 +0000 (17:25 +0300)]
SSL: default DH parameters compatible with OpenSSL 1.1.0.

This is a direct commit to stable as there is no corresponding code
in mainline, default DH parameters were removed in 1aa9650a8154.

9 years agoUpdated OpenSSL used for win32 builds.
Maxim Dounin [Tue, 11 Oct 2016 13:52:48 +0000 (16:52 +0300)]
Updated OpenSSL used for win32 builds.

9 years agoEvent pipe: do not set file's thread_handler if not needed.
Maxim Dounin [Thu, 1 Sep 2016 17:05:23 +0000 (20:05 +0300)]
Event pipe: do not set file's thread_handler if not needed.

This fixes a problem with aio threads and sendfile with aio_write switched
off, as observed with range requests after fc72784b1f52 (1.9.13).  Potential
problems with sendfile in threads were previously described in 9fd738b85fad,
and this seems to be one of them.

The problem occurred as file's thread_handler was set to NULL by event pipe
code after a sendfile thread task was scheduled.  As a result, no sendfile
completion code was executed, and the same buffer was additionally sent
using non-threaded sendfile.  Fix is to avoid modifying file's thread_handler
if aio_write is switched off.

Note that with "aio_write on" it is still possible that sendfile will use
thread_handler as set by event pipe.  This is believed to be safe though,
as handlers used are compatible.

9 years agoSSL: adopted session ticket handling for OpenSSL 1.1.0.
Sergey Kandaurov [Mon, 22 Aug 2016 15:53:21 +0000 (18:53 +0300)]
SSL: adopted session ticket handling for OpenSSL 1.1.0.

Return 1 in the SSL_CTX_set_tlsext_ticket_key_cb() callback function
to indicate that a new session ticket is created, as per documentation.
Until 1.1.0, OpenSSL didn't make a distinction between non-negative
return values.

See https://git.openssl.org/?p=openssl.git;a=commitdiff;h=5c753de for details.

9 years agoSSL: guarded SSL_R_NO_CIPHERS_PASSED not present in OpenSSL 1.1.0.
Sergey Kandaurov [Mon, 8 Aug 2016 10:44:49 +0000 (13:44 +0300)]
SSL: guarded SSL_R_NO_CIPHERS_PASSED not present in OpenSSL 1.1.0.

It was removed in OpenSSL 1.1.0 Beta 3 (pre-release 6).  It was
not used since OpenSSL 1.0.1n and 1.0.2b.

9 years agoHTTP/2: flushing of the SSL buffer in transition to the idle state.
Valentin Bartenev [Tue, 19 Jul 2016 17:34:17 +0000 (20:34 +0300)]
HTTP/2: flushing of the SSL buffer in transition to the idle state.

It fixes potential connection leak if some unsent data was left in the SSL
buffer.  Particularly, that could happen when a client canceled the stream
after the HEADERS frame has already been created.  In this case no other
frames might be produced and the HEADERS frame alone didn't flush the buffer.

9 years agoHTTP/2: refactored ngx_http_v2_send_output_queue().
Valentin Bartenev [Tue, 19 Jul 2016 17:34:02 +0000 (20:34 +0300)]
HTTP/2: refactored ngx_http_v2_send_output_queue().

Now it returns NGX_AGAIN if there's still data to be sent.

9 years agoHTTP/2: fixed send timer handling.
Valentin Bartenev [Tue, 19 Jul 2016 17:31:09 +0000 (20:31 +0300)]
HTTP/2: fixed send timer handling.

Checking for return value of c->send_chain() isn't sufficient since there
are data can be left in the SSL buffer.  Now the wew->ready flag is used
instead.

In particular, this fixed a connection leak in cases when all streams were
closed, but there's still some data to be sent in the SSL buffer and the
client forgot about the connection.

9 years agoHTTP/2: avoid sending output queue if there's nothing to send.
Valentin Bartenev [Tue, 19 Jul 2016 17:30:21 +0000 (20:30 +0300)]
HTTP/2: avoid sending output queue if there's nothing to send.

Particularly this fixes alerts on OS X and NetBSD systems when HTTP/2 is
configured over plain TCP sockets.

On these systems calling writev() with no data leads to EINVAL errors
being logged as "writev() failed (22: Invalid argument) while processing
HTTP/2 connection".

9 years agoHTTP/2: always handle streams in error state.
Valentin Bartenev [Tue, 19 Jul 2016 17:22:44 +0000 (20:22 +0300)]
HTTP/2: always handle streams in error state.

Previously, a stream could be closed by timeout if it was canceled
while its send window was exhausted.

9 years agoHTTP/2: prevented output of the HEADERS frame for canceled streams.
Valentin Bartenev [Tue, 19 Jul 2016 17:22:44 +0000 (20:22 +0300)]
HTTP/2: prevented output of the HEADERS frame for canceled streams.

It's useless to generate HEADERS if the stream has been canceled already.

9 years agoHTTP/2: always send GOAWAY while worker is shutting down.
Valentin Bartenev [Tue, 19 Jul 2016 17:22:44 +0000 (20:22 +0300)]
HTTP/2: always send GOAWAY while worker is shutting down.

Previously, if the worker process exited, GOAWAY was sent to connections in
idle state, but connections with active streams were closed without GOAWAY.

9 years agoUpdated PCRE used for win32 builds.
Maxim Dounin [Tue, 5 Jul 2016 15:30:56 +0000 (18:30 +0300)]
Updated PCRE used for win32 builds.

9 years agoSub filter: eliminate unnecessary buffering.
Roman Arutyunyan [Sat, 2 Jul 2016 12:59:53 +0000 (15:59 +0300)]
Sub filter: eliminate unnecessary buffering.

Previously, when a buffer was processed by the sub filter, its final bytes
could be buffered by the filter even if they don't match any pattern.
This happened because the Boyer-Moore algorithm, employed by the sub filter
since b9447fc457b4 (1.9.4), matches the last characters of patterns prior to
checking other characters.  If the last character is out of scope, initial
bytes of a potential match are buffered until the last character is available.

Now, after receiving a flush or recycled buffer, the filter performs
additional checks to reduce the number of buffered bytes.  The potential match
is checked against the initial parts of all patterns.  Non-matching bytes are
not buffered.  This improves processing of a chunked response from upstream
by sending the entire chunks without buffering unless a partial match is found
at the end of a chunk.

9 years agoSub filter: introduced the ngx_http_sub_match() function.
Roman Arutyunyan [Sat, 2 Jul 2016 12:59:52 +0000 (15:59 +0300)]
Sub filter: introduced the ngx_http_sub_match() function.

No functional changes.

9 years agoHTTP/2: fixed the "http request count is zero" alert.
Valentin Bartenev [Thu, 16 Jun 2016 17:55:11 +0000 (20:55 +0300)]
HTTP/2: fixed the "http request count is zero" alert.

When the stream is terminated the HEADERS frame can still wait in the output
queue.  This frame can't be removed and must be sent to the client anyway,
since HTTP/2 uses stateful compression for headers.  So in order to postpone
closing and freeing memory of such stream the special close stream handler
is set to the write event.  After the HEADERS frame is sent the write event
is called and the stream will be finally closed.

Some events like receiving a RST_STREAM can trigger the read handler of such
stream in closing state and cause unexpected processing that can result in
another attempt to finalize the request.  To prevent it the read handler is
now set to ngx_http_empty_handler.

Thanks to Amazon.

9 years agoHTTP/2: avoid adding Content-Length for requests without body.
Valentin Bartenev [Thu, 16 Jun 2016 17:55:11 +0000 (20:55 +0300)]
HTTP/2: avoid adding Content-Length for requests without body.

There is no reason to add the "Content-Length: 0" header to a proxied request
without body if the header isn't presented in the original request.

Thanks to Amazon.

9 years agoHTTP/2: prevented double termination of a stream.
Valentin Bartenev [Thu, 16 Jun 2016 17:55:11 +0000 (20:55 +0300)]
HTTP/2: prevented double termination of a stream.

According to RFC 7540, an endpoint should not send more than one RST_STREAM
frame for any stream.

Also, now all the data frames will be skipped while termination.

9 years agoHTTP/2: fixed a segfault while processing unbuffered upload.
Valentin Bartenev [Thu, 16 Jun 2016 17:55:11 +0000 (20:55 +0300)]
HTTP/2: fixed a segfault while processing unbuffered upload.

The ngx_http_v2_finalize_connection() closes current stream, but that is an
invalid operation while processing unbuffered upload.  This results in access
to already freed memory, since the upstream module sets a cleanup handler that
also finalizes the request.

9 years agoHTTP/2: unbreak build on MSVC.
Valentin Bartenev [Tue, 24 May 2016 18:54:32 +0000 (21:54 +0300)]
HTTP/2: unbreak build on MSVC.

9 years agoHTTP/2: implemented preread buffer for request body (closes #959).
Valentin Bartenev [Tue, 24 May 2016 14:37:52 +0000 (17:37 +0300)]
HTTP/2: implemented preread buffer for request body (closes #959).

Previously, the stream's window was kept zero in order to prevent a client
from sending the request body before it was requested (see 887cca40ba6a for
details).  Until such initial window was acknowledged all requests with
data were rejected (see 0aa07850922f for details).

That approach revealed a number of problems:

 1. Some clients (notably MS IE/Edge, Safari, iOS applications) show an error
    or even crash if a stream is rejected;

 2. This requires at least one RTT for every request with body before the
    client receives window update and able to send data.

To overcome these problems the new directive "http2_body_preread_size" is
introduced.  It sets the initial window and configures a special per stream
preread buffer that is used to save all incoming data before the body is
requested and processed.

If the directive's value is lower than the default initial window (65535),
as previously, all streams with data will be rejected until the new window
is acknowledged.  Otherwise, no special processing is used and all requests
with data are welcome right from the connection start.

The default value is chosen to be 64k, which is bigger than the default
initial window.  Setting it to zero is fully complaint to the previous
behavior.

9 years agoHTTP/2: the "421 Misdirected Request" response (closes #848).
Valentin Bartenev [Fri, 20 May 2016 15:41:17 +0000 (18:41 +0300)]
HTTP/2: the "421 Misdirected Request" response (closes #848).

Since 4fbef397c753 nginx rejects with the 400 error any attempts of
requesting different host over the same connection, if the relevant
virtual server requires verification of a client certificate.

While requesting hosts other than negotiated isn't something legal
in HTTP/1.x, the HTTP/2 specification explicitly permits such requests
for connection reuse and has introduced a special response code 421.

According to RFC 7540 Section 9.1.2 this code can be sent by a server
that is not configured to produce responses for the combination of
scheme and authority that are included in the request URI.  And the
client may retry the request over a different connection.

Now this code is used for requests that aren't authorized in current
connection.  After receiving the 421 response a client will be able
to open a new connection, provide the required certificate and retry
the request.

Unfortunately, not all clients currently are able to handle it well.
Notably Chrome just shows an error, while at least the latest version
of Firefox retries the request over a new connection.

9 years agoVersion bump.
Maxim Dounin [Tue, 18 Oct 2016 14:19:51 +0000 (17:19 +0300)]
Version bump.

9 years agorelease-1.10.1 tag
Maxim Dounin [Tue, 31 May 2016 13:47:01 +0000 (16:47 +0300)]
release-1.10.1 tag

9 years agonginx-1.10.1-RELEASE release-1.10.1
Maxim Dounin [Tue, 31 May 2016 13:47:01 +0000 (16:47 +0300)]
nginx-1.10.1-RELEASE

9 years agoCore: skip special buffers on writing (ticket #981).
Maxim Dounin [Tue, 31 May 2016 02:13:30 +0000 (05:13 +0300)]
Core: skip special buffers on writing (ticket #981).

A special last buffer with cl->buf->pos set to NULL can be present in
a chain when writing request body if chunked encoding was used.  This
resulted in a NULL pointer dereference if it happened to be the only
buffer left after a do...while loop iteration in ngx_write_chain_to_file().

The problem originally appeared in nginx 1.3.9 with chunked encoding
support.  Additionally, rev. 3832b608dc8d (nginx 1.9.13) changed the
minimum number of buffers to trigger this from IOV_MAX (typically 1024)
to NGX_IOVS_PREALLOCATE (typically 64).

Fix is to skip such buffers in ngx_chain_to_iovec(), much like it is
done in other places.

9 years agoUpdated OpenSSL used for win32 builds.
Maxim Dounin [Tue, 24 May 2016 14:44:01 +0000 (17:44 +0300)]
Updated OpenSSL used for win32 builds.

9 years agoVersion bump.
Maxim Dounin [Mon, 30 May 2016 23:21:38 +0000 (02:21 +0300)]
Version bump.

10 years agorelease-1.10.0 tag
Maxim Dounin [Tue, 26 Apr 2016 13:31:18 +0000 (16:31 +0300)]
release-1.10.0 tag

10 years agonginx-1.10.0-RELEASE release-1.10.0
Maxim Dounin [Tue, 26 Apr 2016 13:31:18 +0000 (16:31 +0300)]
nginx-1.10.0-RELEASE

10 years agoStable branch.
Maxim Dounin [Tue, 26 Apr 2016 13:30:30 +0000 (16:30 +0300)]
Stable branch.

10 years agorelease-1.9.15 tag
Maxim Dounin [Tue, 19 Apr 2016 16:02:37 +0000 (19:02 +0300)]
release-1.9.15 tag

10 years agonginx-1.9.15-RELEASE release-1.9.15
Maxim Dounin [Tue, 19 Apr 2016 16:02:37 +0000 (19:02 +0300)]
nginx-1.9.15-RELEASE

10 years agoHTTP/2: send the output queue after emitting WINDOW_UPDATE.
Valentin Bartenev [Tue, 19 Apr 2016 14:38:49 +0000 (17:38 +0300)]
HTTP/2: send the output queue after emitting WINDOW_UPDATE.

The WINDOW_UPDATE frame could be left in the output queue for an indefinite
period of time resulting in the request timeout.

This might happen if reading of the body was triggered by an event unrelated
to client connection, e.g. by the limit_req timer.

10 years agoHTTP/2: skip data frames in case of internal errors.
Valentin Bartenev [Tue, 19 Apr 2016 14:38:49 +0000 (17:38 +0300)]
HTTP/2: skip data frames in case of internal errors.

This prevents possible processing of such frames and triggering
rb->post_handler if an error occurred during r->request_body
initialization.

10 years agoHTTP/2: don't send WINDOW_UPDATE for an empty request body.
Valentin Bartenev [Tue, 19 Apr 2016 14:38:49 +0000 (17:38 +0300)]
HTTP/2: don't send WINDOW_UPDATE for an empty request body.

Particularly this prevents sending WINDOW_UPDATE with zero delta
which can result in PROTOCOL_ERROR.

Also removed surplus setting of no_flow_control to 0.

10 years agoThread pools: memory barriers in task completion notifications.
Maxim Dounin [Tue, 19 Apr 2016 14:18:28 +0000 (17:18 +0300)]
Thread pools: memory barriers in task completion notifications.

The ngx_thread_pool_done object isn't volatile, and at least some
compilers assume that it is permitted to reorder modifications of
volatile and non-volatile objects.  Added appropriate ngx_memory_barrier()
calls to make sure all modifications will happen before the lock is released.

Reported by Mindaugas Rasiukevicius,
http://mailman.nginx.org/pipermail/nginx-devel/2016-April/008160.html.

10 years agoHTTP/2: write logs when refusing streams with data.
Maxim Dounin [Mon, 18 Apr 2016 18:18:24 +0000 (21:18 +0300)]
HTTP/2: write logs when refusing streams with data.

Refusing streams is known to be incorrectly handled at least by IE, Edge
and Safari.  Make sure to provide appropriate logging to simplify fixing
this in the affected browsers.

10 years agoHTTP/2: send WINDOW_UPDATE instead of RST_STREAM with NO_ERROR.
Valentin Bartenev [Thu, 14 Apr 2016 12:14:15 +0000 (15:14 +0300)]
HTTP/2: send WINDOW_UPDATE instead of RST_STREAM with NO_ERROR.

After the 92464ebace8e change, it has been discovered that not all
clients follow the RFC and handle RST_STREAM with NO_ERROR properly.

Notably, Chrome currently interprets it as INTERNAL_ERROR and discards
the response.

As a workaround, instead of RST_STREAM the maximum stream window update
will be sent, which will let client to send up to 2 GB of a request body
data before getting stuck on flow control.  All the received data will
be silently discarded.

See for details:
http://mailman.nginx.org/pipermail/nginx-devel/2016-April/008143.html
https://bugs.chromium.org/p/chromium/issues/detail?id=603182

10 years agoHTTP/2: refuse streams with data until SETTINGS is acknowledged.
Valentin Bartenev [Thu, 14 Apr 2016 12:14:15 +0000 (15:14 +0300)]
HTTP/2: refuse streams with data until SETTINGS is acknowledged.

A client is allowed to send requests before receiving and acknowledging
the SETTINGS frame.  Such a client having a wrong idea about the stream's
could send the request body that nginx isn't ready to process.

The previous behavior was to send RST_STREAM with FLOW_CONTROL_ERROR in
such case, but it didn't allow retrying requests that have been rejected.

10 years agoHTTP/2: deduplicated some code in ngx_http_v2_state_headers().
Valentin Bartenev [Thu, 14 Apr 2016 12:14:15 +0000 (15:14 +0300)]
HTTP/2: deduplicated some code in ngx_http_v2_state_headers().

No functional changes.

10 years agoFastCGI: skip special bufs in buffered request body chain.
Valentin Bartenev [Mon, 11 Apr 2016 15:42:34 +0000 (18:42 +0300)]
FastCGI: skip special bufs in buffered request body chain.

This prevents forming empty records out of such buffers.  Particularly it fixes
double end-of-stream records with chunked transfer encoding, or when HTTP/2 is
used and the END_STREAM flag has been sent without data.  In both cases there
is an empty buffer at the end of the request body chain with the "last_buf"
flag set.

The canonical libfcgi, as well as php implementation, tolerates such records,
while the HHVM parser is more strict and drops the connection (ticket #950).

10 years agoFixed NGX_CONF_TAKE1/NGX_CONF_FLAG misuse (as in e444e8f6538b).
Ruslan Ermilov [Tue, 12 Apr 2016 16:01:56 +0000 (19:01 +0300)]
Fixed NGX_CONF_TAKE1/NGX_CONF_FLAG misuse (as in e444e8f6538b).

10 years agoFixed typos.
Alessandro Ghedini [Mon, 11 Apr 2016 15:47:11 +0000 (16:47 +0100)]
Fixed typos.

10 years agoRemoved redundant "u" format specifier.
Ruslan Ermilov [Fri, 8 Apr 2016 12:03:38 +0000 (15:03 +0300)]
Removed redundant "u" format specifier.

It is implied for "x" and "X".

10 years agoSimplified ngx_unix_recv() and ngx_readv_chain().
Ruslan Ermilov [Fri, 8 Apr 2016 13:49:35 +0000 (16:49 +0300)]
Simplified ngx_unix_recv() and ngx_readv_chain().

This makes ngx_unix_recv() and ngx_udp_unix_recv() differ minimally.

10 years agoMerged implementations of ngx_unix_recv().
Valentin Bartenev [Fri, 8 Apr 2016 13:41:45 +0000 (16:41 +0300)]
Merged implementations of ngx_unix_recv().

There's no real need in two separate implementations,
with and without kqueue support.

10 years agoFixed small inconsistency in handling EOF among receive functions.
Valentin Bartenev [Fri, 8 Apr 2016 13:39:49 +0000 (16:39 +0300)]
Fixed small inconsistency in handling EOF among receive functions.

Now all functions always drop the ready flag in this case.

10 years agoMerged implementations of ngx_udp_unix_recv().
Valentin Bartenev [Fri, 8 Apr 2016 13:38:42 +0000 (16:38 +0300)]
Merged implementations of ngx_udp_unix_recv().

There's no real need in two separate implementations,
with and without kqueue support.

10 years agoFixed spelling.
Josh Soref [Thu, 7 Apr 2016 08:50:13 +0000 (11:50 +0300)]
Fixed spelling.

10 years agoVersion bump.
Ruslan Ermilov [Thu, 7 Apr 2016 16:09:42 +0000 (19:09 +0300)]
Version bump.

10 years agorelease-1.9.14 tag
Maxim Dounin [Tue, 5 Apr 2016 14:57:08 +0000 (17:57 +0300)]
release-1.9.14 tag

10 years agonginx-1.9.14-RELEASE release-1.9.14
Maxim Dounin [Tue, 5 Apr 2016 14:57:08 +0000 (17:57 +0300)]
nginx-1.9.14-RELEASE

10 years agoCompatibility with FreeBSD 2.2.9.
Maxim Dounin [Fri, 1 Apr 2016 13:38:31 +0000 (16:38 +0300)]
Compatibility with FreeBSD 2.2.9.

Added (RTLD_NOW | RTLD_GLOBAL) to dlopen() test.  There is no RTLD_GLOBAL
on FreeBSD 2.2.9.

Added uint32_t test, with fallback to u_int32_t, similar to uint64_t one.
Added fallback to u_int32_t in in_addr_t test.

With these changes it is now possible to compile nginx on FreeBSD 2.2.9
with only few minor warnings (assuming -Wno-error).

10 years agoConfigure: improved multiple types handling in auto/types/typedef.
Maxim Dounin [Fri, 1 Apr 2016 13:38:30 +0000 (16:38 +0300)]
Configure: improved multiple types handling in auto/types/typedef.

10 years agoConfigure: fixed autotest source code logging.
Maxim Dounin [Fri, 1 Apr 2016 13:38:28 +0000 (16:38 +0300)]
Configure: fixed autotest source code logging.

Fixed a regression introduced in rev. 434548349838 that prevented
auto/types/sizeof and auto/types/typedef properly reporting autotest
source code to autoconf.err in case of test failure.

10 years agoHTTP/2: support for unbuffered upload of request body.
Valentin Bartenev [Fri, 1 Apr 2016 12:57:10 +0000 (15:57 +0300)]
HTTP/2: support for unbuffered upload of request body.

10 years agoHTTP/2: rewritten handling of request body.
Valentin Bartenev [Fri, 1 Apr 2016 12:56:03 +0000 (15:56 +0300)]
HTTP/2: rewritten handling of request body.

There are two improvements:

  1. Support for request body filters;

  2. Receiving of request body is started only after
     the ngx_http_read_client_request_body() call.

The last one fixes the problem when the client_max_body_size value might not be
respected from the right location if the location was changed either during the
process of receiving body or after the whole body had been received.

10 years agoHTTP/2: sending RST_STREAM with NO_ERROR to discard request body.
Valentin Bartenev [Fri, 1 Apr 2016 12:56:03 +0000 (15:56 +0300)]
HTTP/2: sending RST_STREAM with NO_ERROR to discard request body.

RFC 7540 states that "A server can send a complete response prior to the client
sending an entire request if the response does not depend on any portion of the
request that has not been sent and received.  When this is true, a server MAY
request that the client abort transmission of a request without error by sending
a RST_STREAM with an error code of NO_ERROR after sending a complete response
(i.e., a frame with the END_STREAM flag)."

This should prevent a client from blocking on the stream window, since it isn't
maintained for closed streams.  Currently, quite big initial stream windows are
used, so such blocking is very unlikly, but that will be changed in the further
patches.

10 years agoCore: removed incorrect GCC 2.7 check.
Maxim Dounin [Fri, 1 Apr 2016 10:17:12 +0000 (13:17 +0300)]
Core: removed incorrect GCC 2.7 check.

It was broken since introduction (__GNU__ instead of __GNUC__) and did
nothing.  Moreover, GCC 2.7 is happy with the normal version of the code.

Reported by Joel Cunningham,
http://mailman.nginx.org/pipermail/nginx-devel/2016-March/007964.html.

10 years agoTrailing space fix.
Maxim Dounin [Fri, 1 Apr 2016 01:17:00 +0000 (04:17 +0300)]
Trailing space fix.

10 years agoSSL: SSLeay_version() is deprecated in OpenSSL 1.1.0.
Maxim Dounin [Thu, 31 Mar 2016 20:38:38 +0000 (23:38 +0300)]
SSL: SSLeay_version() is deprecated in OpenSSL 1.1.0.

SSLeay_version() and SSLeay() are no longer available if OPENSSL_API_COMPAT
is set to 0x10100000L.  Switched to using OpenSSL_version() instead.

Additionally, we now compare version strings instead of version numbers,
and this correctly works for LibreSSL as well.

10 years agoSSL: X509 was made opaque in OpenSSL 1.1.0.
Sergey Kandaurov [Thu, 31 Mar 2016 20:38:37 +0000 (23:38 +0300)]
SSL: X509 was made opaque in OpenSSL 1.1.0.

To increment reference counters we now use newly introduced X509_up_ref()
function.

10 years agoSSL: EVP_MD_CTX was made opaque in OpenSSL 1.1.0.
Sergey Kandaurov [Thu, 31 Mar 2016 20:38:36 +0000 (23:38 +0300)]
SSL: EVP_MD_CTX was made opaque in OpenSSL 1.1.0.

10 years agoSSL: RSA_generate_key() is deprecated in OpenSSL 1.1.0.
Maxim Dounin [Thu, 31 Mar 2016 20:38:34 +0000 (23:38 +0300)]
SSL: RSA_generate_key() is deprecated in OpenSSL 1.1.0.

OpenSSL removed support for all 40 and 56 bit ciphers.

10 years agoSSL: initialization changes for OpenSSL 1.1.0.
Maxim Dounin [Thu, 31 Mar 2016 20:38:33 +0000 (23:38 +0300)]
SSL: initialization changes for OpenSSL 1.1.0.

OPENSSL_config() deprecated in OpenSSL 1.1.0.  Additionally,
SSL_library_init(), SSL_load_error_strings() and OpenSSL_add_all_algorithms()
are no longer available if OPENSSL_API_COMPAT is set to 0x10100000L.

The OPENSSL_init_ssl() function is now used instead with appropriate
arguments to trigger the same behaviour.  The configure test changed to
use SSL_CTX_set_options().

Deinitialization now happens automatically in OPENSSL_cleanup() called
via atexit(3), so we no longer call EVP_cleanup() and ENGINE_cleanup()
directly.

10 years agoSSL: get_session callback changed in OpenSSL 1.1.0.
Maxim Dounin [Thu, 31 Mar 2016 20:38:32 +0000 (23:38 +0300)]
SSL: get_session callback changed in OpenSSL 1.1.0.

10 years agoSSL: guarded error codes not present in OpenSSL 1.1.0.
Maxim Dounin [Thu, 31 Mar 2016 20:38:31 +0000 (23:38 +0300)]
SSL: guarded error codes not present in OpenSSL 1.1.0.

10 years agoSSL: reasonable version for LibreSSL.
Maxim Dounin [Thu, 31 Mar 2016 20:38:29 +0000 (23:38 +0300)]
SSL: reasonable version for LibreSSL.

LibreSSL defines OPENSSL_VERSION_NUMBER to 0x20000000L, but uses an old
API derived from OpenSSL at the time LibreSSL forked.  As a result, every
version check we use to test for new API elements in newer OpenSSL versions
requires an explicit check for LibreSSL.

To reduce clutter, redefine OPENSSL_VERSION_NUMBER to 0x1000107fL if
LibreSSL is used.  The same is done by FreeBSD port of LibreSSL.

10 years agoRemoved the prototype mysql module.
Ruslan Ermilov [Thu, 31 Mar 2016 19:33:26 +0000 (22:33 +0300)]
Removed the prototype mysql module.

10 years agoFixed ngx_os_signal_process() prototype.
Ruslan Ermilov [Thu, 31 Mar 2016 19:00:33 +0000 (22:00 +0300)]
Fixed ngx_os_signal_process() prototype.

10 years agoFixed ngx_pid_t formatting in ngx_sprintf() and logging.
Sergey Kandaurov [Wed, 30 Mar 2016 23:34:04 +0000 (02:34 +0300)]
Fixed ngx_pid_t formatting in ngx_sprintf() and logging.

10 years agoFixed format specifiers in ngx_sprintf().
Sergey Kandaurov [Wed, 30 Mar 2016 23:34:00 +0000 (02:34 +0300)]
Fixed format specifiers in ngx_sprintf().

10 years agoFixed logging.
Sergey Kandaurov [Wed, 30 Mar 2016 23:33:57 +0000 (02:33 +0300)]
Fixed logging.

10 years agoEvents: fixed logging.
Sergey Kandaurov [Wed, 30 Mar 2016 23:33:55 +0000 (02:33 +0300)]
Events: fixed logging.

10 years agoFixed logging with variable field width.
Sergey Kandaurov [Wed, 30 Mar 2016 23:33:53 +0000 (02:33 +0300)]
Fixed logging with variable field width.

10 years agoFixed logging in close error handling.
Sergey Kandaurov [Wed, 30 Mar 2016 23:33:50 +0000 (02:33 +0300)]
Fixed logging in close error handling.

10 years agoFixed mistranslated phrase.
Ruslan Ermilov [Wed, 30 Mar 2016 09:07:19 +0000 (12:07 +0300)]
Fixed mistranslated phrase.

10 years agoEvents: fixed test building with eventport on OS X.
Ruslan Ermilov [Wed, 30 Mar 2016 08:57:28 +0000 (11:57 +0300)]
Events: fixed test building with eventport on OS X.

Broken in d17f0584006f (1.9.13).

10 years agoStyle.
Ruslan Ermilov [Wed, 30 Mar 2016 08:52:16 +0000 (11:52 +0300)]
Style.

10 years agoVersion bump.
Ruslan Ermilov [Wed, 30 Mar 2016 08:52:07 +0000 (11:52 +0300)]
Version bump.

10 years agorelease-1.9.13 tag
Maxim Dounin [Tue, 29 Mar 2016 15:09:30 +0000 (18:09 +0300)]
release-1.9.13 tag

10 years agonginx-1.9.13-RELEASE release-1.9.13
Maxim Dounin [Tue, 29 Mar 2016 15:09:30 +0000 (18:09 +0300)]
nginx-1.9.13-RELEASE

10 years agoUpdated OpenSSL used for win32 builds.
Maxim Dounin [Tue, 29 Mar 2016 06:54:11 +0000 (09:54 +0300)]
Updated OpenSSL used for win32 builds.

10 years agoWin32: replaced NGX_EXDEV with more appropriate error code.
Maxim Dounin [Tue, 29 Mar 2016 06:52:15 +0000 (09:52 +0300)]
Win32: replaced NGX_EXDEV with more appropriate error code.

Correct error code for NGX_EXDEV on Windows is ERROR_NOT_SAME_DEVICE,
"The system cannot move the file to a different disk drive".

Previously used ERROR_WRONG_DISK is about wrong diskette in the drive and
is not appropriate.

There is no real difference though, as MoveFile() is able to copy files
between disk drives, and will fail with ERROR_ACCESS_DENIED when asked
to copy directories.  The ERROR_NOT_SAME_DEVICE error is only used
by MoveFileEx() when called without the MOVEFILE_COPY_ALLOWED flag.

10 years agoWin32: additional error code NGX_EEXIST_FILE (ticket #910).
Maxim Dounin [Tue, 29 Mar 2016 06:51:46 +0000 (09:51 +0300)]
Win32: additional error code NGX_EEXIST_FILE (ticket #910).

On Windows there are two possible error codes which correspond to
the EEXIST error code: ERROR_FILE_EXISTS used by CreateFile(CREATE_NEW),
and ERROR_ALREADY_EXISTS used by CreateDirectory().

MoveFile() seems to use both: ERROR_ALREADY_EXISTS when moving within
one filesystem, and ERROR_FILE_EXISTS when copying a file to a different
drive.

10 years agoUpstream: proxy_next_upstream non_idempotent.
Maxim Dounin [Mon, 28 Mar 2016 16:50:19 +0000 (19:50 +0300)]
Upstream: proxy_next_upstream non_idempotent.

By default, requests with non-idempotent methods (POST, LOCK, PATCH)
are no longer retried in case of errors if a request was already sent
to a backend.  Previous behaviour can be restored by using
"proxy_next_upstream ... non_idempotent".

10 years agoUpstream: cached connections now tested against next_upstream.
Maxim Dounin [Mon, 28 Mar 2016 16:49:52 +0000 (19:49 +0300)]
Upstream: cached connections now tested against next_upstream.

Much like normal connections, cached connections are now tested against
u->conf->next_upstream, and u->state->status is now always set.

This allows to disable additional tries even with upstream keepalive
by using "proxy_next_upstream off".

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.