summaryrefslogtreecommitdiffhomepage
path: root/src (follow)
AgeCommit message (Collapse)AuthorFilesLines
2020-08-18Merged with the default branch.Roman Arutyunyan13-111/+282
2020-08-18QUIC: coalesce neighbouring stream send buffers.Roman Arutyunyan1-110/+166
Previously a single STREAM frame was created for each buffer in stream output chain which is wasteful with respect to memory. The following changes were made in the stream send code: - ngx_quic_stream_send_chain() no longer calls ngx_quic_stream_send() and got a separate implementation that coalesces neighbouring buffers into a single frame - the new ngx_quic_stream_send_chain() respects the limit argument, which fixes sendfile_max_chunk and limit_rate - ngx_quic_stream_send() is reimplemented to call ngx_quic_stream_send_chain() - stream frame size limit is moved out to a separate function ngx_quic_max_stream_frame() - flow control is moved out to a separate function ngx_quic_max_stream_flow() - ngx_quic_stream_send_chain() is relocated next to ngx_quic_stream_send()
2020-08-14QUIC: packet based bytes_in_flight accounting.Sergey Kandaurov2-9/+30
A packet size is kept in one of the frames belonging to the packet.
2020-08-14QUIC: fixed leak of bytes_in_flight on keys discard.Sergey Kandaurov1-2/+21
This applies to discarding Initial and Handshake keys.
2020-08-14QUIC: fixed leak of bytes_in_flight attributed to lost packets.Sergey Kandaurov1-0/+1
2020-08-10Core: reusing connections in advance.Maxim Dounin1-6/+5
Reworked connections reuse, so closing connections is attempted in advance, as long as number of free connections is less than 1/16 of worker connections configured. This ensures that new connections can be handled even if closing a reusable connection requires some time, for example, for a lingering close (ticket #2017). The 1/16 ratio is selected to be smaller than 1/8 used for disabling accept when working with accept mutex, so nginx will try to balance new connections to different workers first, and will start reusing connections only if this won't help.
2020-08-10Core: added a warning about reusing connections.Maxim Dounin2-0/+14
Previously, reusing connections happened silently and was only visible in monitoring systems. This was shown to be not very user-friendly, and administrators often didn't realize there were too few connections available to withstand the load, and configured timeouts (keepalive_timeout and http2_idle_timeout) were effectively reduced to keep things running. To provide at least some information about this, a warning is now logged (at most once per second, to avoid flooding the logs).
2020-08-10SSL: disabled sending shutdown after ngx_http_test_reading().Maxim Dounin1-0/+6
Sending shutdown when ngx_http_test_reading() detects the connection is closed can result in "SSL_shutdown() failed (SSL: ... bad write retry)" critical log messages if there are blocked writes. Fix is to avoid sending shutdown via the c->ssl->no_send_shutdown flag, similarly to how it is done in ngx_http_keepalive_handler() for kqueue when pending EOF is detected. Reported by Jan Prachaƙ (http://mailman.nginx.org/pipermail/nginx-devel/2018-December/011702.html).
2020-08-10HTTP/2: fixed c->timedout flag on timed out connections.Maxim Dounin1-0/+1
Without the flag, SSL shutdown is attempted on such connections, resulting in useless work and/or bogus "SSL_shutdown() failed (SSL: ... bad write retry)" critical log messages if there are blocked writes.
2020-08-10SSL: fixed shutdown handling.Maxim Dounin1-31/+48
Previously, bidirectional shutdown never worked, due to two issues in the code: 1. The code only tested SSL_ERROR_WANT_READ and SSL_ERROR_WANT_WRITE when there was an error in the error queue, which cannot happen. The bug was introduced in an attempt to fix unexpected error logging as reported with OpenSSL 0.9.8g (http://mailman.nginx.org/pipermail/nginx/2008-January/003084.html). 2. The code never called SSL_shutdown() for the second time to wait for the peer's close_notify alert. This change fixes both issues. Note that after this change bidirectional shutdown is expected to work for the first time, so c->ssl->no_wait_shutdown now makes a difference. This is not a problem for HTTP code which always uses c->ssl->no_wait_shutdown, but might be a problem for stream and mail code, as well as 3rd party modules. To minimize the effect of the change, the timeout, which was used to be 30 seconds and not configurable, though never actually used, is now set to 3 seconds. It is also expanded to apply to both SSL_ERROR_WANT_READ and SSL_ERROR_WANT_WRITE, so timeout is properly set if writing to the socket buffer is not possible.
2020-08-06Request body: optimized handling of small chunks.Maxim Dounin1-0/+25
If there is a previous buffer, copy small chunks into it instead of allocating additional buffer.
2020-08-06Request body: allowed large reads on chunk boundaries.Maxim Dounin1-8/+113
If some additional data from a pipelined request happens to be read into the body buffer, we copy it to r->header_in or allocate an additional large client header buffer for it.
2020-08-06Request body: all read data are now sent to filters.Maxim Dounin1-43/+10
This is a prerequisite for the next change to allow large reads on chunk boundaries.
2020-08-06Added size check to ngx_http_alloc_large_header_buffer().Maxim Dounin1-0/+6
This ensures that copying won't write more than the buffer size even if the buffer comes from hc->free and it is smaller than the large client header buffer size in the virtual host configuration. This might happen if size of large client header buffers is different in name-based virtual hosts, similarly to the problem with number of buffers fixed in 6926:e662cbf1b932.
2020-08-03QUIC: handle client RESET_STREAM and STOP_SENDING.Roman Arutyunyan1-10/+65
For RESET_STREAM the c->read->error flag is set. For STOP_SENDING the c->write->error flag is set.
2020-08-11QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.Roman Arutyunyan1-91/+144
Creating client-initiated streams is moved from ngx_quic_handle_stream_frame() to a separate function ngx_quic_create_client_stream(). This function is responsible for creating streams with lower ids as well. Also, simplified and fixed initial data buffering in ngx_quic_handle_stream_frame(). It is now done before calling the initial handler as the handler can destroy the stream.
2020-08-11QUIC: fixed ngx_http_test_reading() for QUIC streams.Roman Arutyunyan2-3/+26
Previously this function generated an error trying to figure out if client shut down the write end of the connection. The reason for this error was that a QUIC stream has no socket descriptor. However checking for eof is not the right thing to do for an HTTP/3 QUIC stream since HTTP/3 clients are expected to shut down the write end of the stream after sending the request. Now the function handles QUIC streams separately. It checks if c->read->error is set. The error flags for c->read and c->write are now set for all streams when closing the QUIC connection instead of setting the pending_eof flag.
2020-08-07QUIC: fixed ACK Ranges processing.Sergey Kandaurov1-7/+10
According to quic-transport draft 29, section 19.3.1: The value of the Gap field establishes the largest packet number value for the subsequent ACK Range using the following formula: largest = previous_smallest - gap - 2 Thus, given a largest packet number for the range, the smallest value is determined by the formula: smallest = largest - ack_range While here, changed min/max to uint64_t for consistency.
2020-08-07QUIC: fixed possible use-after-free on stream cleanup.Sergey Kandaurov1-1/+3
A QUIC stream could be destroyed by handler while in ngx_quic_stream_input(). To detect this, ngx_quic_find_stream() is used to check that it still exists. Previously, a stream id was passed to this routine off the frame structure. In case of stream cleanup, it is freed along with other frames belonging to the stream on cleanup. Then, a cleanup handler reuses last frames to update MAX_STREAMS and serve other purpose. Thus, ngx_quic_find_stream() is passed a reused frame with zeroed out part pointed by stream_id. If a stream with id 0x0 still exists, this leads to use-after-free.
2020-07-28QUIC: fixed format specifiers and removed casts.Sergey Kandaurov1-8/+8
2020-07-28QUIC: consistent Stream ID logging format.Sergey Kandaurov2-9/+11
2020-07-27FastCGI: fixed zero size buf alerts on extra data (ticket #2018).Maxim Dounin1-6/+22
After 05e42236e95b (1.19.1) responses with extra data might result in zero size buffers being generated and "zero size buf" alerts in writer (if f->rest happened to be 0 when processing additional stdout data).
2020-07-27Core: enclosed parameters of the ngx_buf.h macros in parentheses.balus1-10/+10
2020-07-23OCSP: fixed certificate reference leak.Sergey Kandaurov1-0/+9
2020-07-23HTTP/3: server pushes.Roman Arutyunyan7-13/+1020
New directives are added: - http3_max_concurrent_pushes - http3_push - http3_push_preload
2020-07-27QUIC: limited the number of client-initiated streams.Roman Arutyunyan1-92/+85
The limits on active bidi and uni client streams are maintained at their initial values initial_max_streams_bidi and initial_max_streams_uni by sending a MAX_STREAMS frame upon each client stream closure. Also, the following is changed for data arriving to non-existing streams: - if a stream was already closed, such data is ignored - when creating a new stream, all streams of the same type with lower ids are created too
2020-07-27QUIC: limited the number of server-initiated streams.Roman Arutyunyan3-26/+111
Also, ngx_quic_create_uni_stream() is replaced with ngx_quic_open_stream() which is capable of creating a bidi stream.
2020-07-22Xslt: disabled ranges.Roman Arutyunyan1-0/+1
Previously, the document generated by the xslt filter was always fully sent to client even if a range was requested and response status was 206 with appropriate Content-Range. The xslt module is unable to serve a range because of suspending the header filter chain. By the moment full response xml is buffered by the xslt filter, range header filter is not called yet, but the range body filter has already been called and did nothing. The fix is to disable ranges by resetting the r->allow_ranges flag much like the image filter that employs a similar technique.
2020-07-21Core: close PID file when writing fails.Ruslan Ermilov1-2/+5
Reported by Jinhua Tan.
2020-07-14HTTP/3: support $server_protocol variable.Roman Arutyunyan3-4/+6
Now it holds "HTTP/3.0". Previously it was empty.
2020-07-23Style: moved function declarations to match usual code style.Roman Arutyunyan1-11/+9
Plus a few other minor style changes.
2020-07-23HTTP/3: renamed server configuration variables from v3cf to h3scf.Roman Arutyunyan4-26/+26
Now they are similar to HTTP/2 where they are called h2scf.
2020-07-13HTTP/3: renamed ngx_http_v3.c to ngx_http_v3_encode.c.Roman Arutyunyan1-0/+0
The file contains only encoding functions.
2020-07-13HTTP/3: encode frame ids with ngx_http_v3_encode_varlen_int().Roman Arutyunyan1-4/+8
Even though typically frame ids fit into a single byte, calling ngx_http_v3_encode_varlen_int() adds to the code clarity.
2020-07-23HTTP/3: generate Location response header for absolute redirects.Roman Arutyunyan1-2/+81
2020-07-13HTTP/3: header encoding functions.Roman Arutyunyan3-90/+226
2020-07-22QUIC: fixed bulding perl module by reducing header pollution.Sergey Kandaurov4-2/+5
The ngx_http_perl_module module doesn't have a notion of including additional search paths through --with-cc-opt, which results in compile error incomplete type 'enum ssl_encryption_level_t' when building nginx without QUIC support. The enum is visible from quic event headers and eventually pollutes ngx_core.h. The fix is to limit including headers to compile units that are real consumers.
2020-07-22SSL: fixed compilation without QUIC after 0d2b2664b41c.Roman Arutyunyan1-0/+2
2020-07-22HTTP/3: do not call shutdown() for QUIC streams.Roman Arutyunyan1-5/+7
Previously, this triggered an alert "shutdown() failed" in error log.
2020-07-21QUIC: eliminated connection handler argument in ngx_quic_run().Roman Arutyunyan4-14/+8
Now c->listening->handler() is called instead.
2020-07-21QUIC: added "quic" listen parameter in Stream.Roman Arutyunyan9-11/+442
Also, introduced ngx_stream_quic_module.
2020-07-21QUIC: added "quic" listen parameter.Roman Arutyunyan17-394/+578
The parameter allows processing HTTP/0.9-2 over QUIC. Also, introduced ngx_http_quic_module and moved QUIC settings there
2020-07-18QUIC: do not verify the selected ALPN protocol.Roman Arutyunyan2-8/+1
The right protocol is selected by the HTTP code. In the QUIC code only verify that some protocol was selected and trigger an error otherwise.
2020-07-18QUIC: fixed stream read event log.Roman Arutyunyan1-2/+2
Previously, the main connection log was there. Now it's the stream connection log.
2020-07-20Fixed format specifiers.Sergey Kandaurov4-45/+44
2020-07-16QUIC: added anti-amplification limit.Vladimir Homutov1-0/+25
According to quic-transport draft 29, section 21.12.1.1: Prior to validation, endpoints are limited in what they are able to send. During the handshake, a server cannot send more than three times the data it receives; clients that initiate new connections or migrate to a new network path are limited.
2020-07-16QUIC: added limit of queued data.Vladimir Homutov3-15/+32
The ngx_quic_queue_frame() functions puts a frame into send queue and schedules a push timer to actually send data. The patch adds tracking for data amount in the queue and sends data immediately if amount of data exceeds limit.
2020-07-16QUIC: implemented probe timeout (PTO) calculation.Vladimir Homutov2-9/+60
2020-07-13QUIC: reworked retransmission mechanism.Vladimir Homutov2-63/+75
Instead of timer-based retransmissions with constant packet lifetime, this patch implements ack-based loss detection and probe timeout for the cases, when no ack is received, according to the quic-recovery draft 29.
2020-07-15QUIC: reworked ngx_quic_send_frames() function.Vladimir Homutov1-44/+29
Instead of returning NGX_DONE/NGX_OK, the function now itself moves passed frames range into sent queue and sets PTO timer if required.