summaryrefslogtreecommitdiffhomepage
path: root/src (follow)
AgeCommit message (Collapse)AuthorFilesLines
2017-04-18Core: removed extra ngx_alloc() and ngx_calloc() prototypes.Sergey Kandaurov1-3/+0
2017-04-17Enabled IPV6_RECVPKTINFO / IPV6_PKTINFO on macOS.Sergey Kandaurov1-0/+3
This change allows setting the destination IPv6 address of a UDP datagram received on a wildcard socket.
2017-04-11Added support for the "308 Permanent Redirect" (ticket #877).Simon Leblanc6-4/+20
2017-04-03Mail: configurable socket buffer sizes.Vladimir Homutov3-1/+39
The "rcvbuf" and "sndbuf" parameters are now supported by the "listen" directive.
2017-04-03Stream: configurable socket buffer sizes.Vladimir Homutov3-1/+39
The "rcvbuf" and "sndbuf" parameters are now supported by the "listen" directive.
2017-04-12Core: improved JSON escaping.Valentin Bartenev1-5/+42
Two-character representations are now used for \b, \f, \n, \r, and \t.
2017-04-12Use ngx_calloc_buf() where appropriate.Ruslan Ermilov9-12/+12
2017-04-12Version bump.Ruslan Ermilov1-2/+2
2017-03-24Upstream: allow recovery from "429 Too Many Requests" response.Piotr Sikora6-5/+16
This change adds "http_429" parameter to "proxy_next_upstream" for retrying rate-limited requests, and to "proxy_cache_use_stale" for serving stale cached responses after being rate-limited. Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2017-03-24Added support for "429 Too Many Requests" response (RFC6585).Piotr Sikora3-8/+29
This change adds reason phrase in status line and pretty response body when "429" status code is used in "return", "limit_conn_status" and/or "limit_req_status" directives. Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2017-04-03Fixed type.hucongcong1-2/+2
2017-03-31Slice filter: prevented slice redirection (ticket #1219).Roman Arutyunyan1-1/+11
When a slice subrequest was redirected to a new location, its context was lost. After its completion, a new slice subrequest for the same slice was created. This could lead to infinite loop. Now the slice module makes sure each slice subrequest starts output with the slice context available.
2017-03-28Slice filter: allowed at most one subrequest at a time.Roman Arutyunyan1-12/+16
Previously, if slice main request write handler was called while a slice subrequest was running, a new subrequest for the same slice was started.
2017-04-02Moved handling of wev->delayed to the connection event handler.Maxim Dounin4-78/+26
With post_action or subrequests, it is possible that the timer set for wev->delayed will expire while the active subrequest write event handler is not ready to handle this. This results in request hangs as observed with limit_rate / sendfile_max_chunk and post_action (ticket #776) or subrequests (ticket #1228). Moving the handling to the connection event handler fixes the hangs observed, and also slightly simplifies the code.
2017-04-02Perl: fixed delaying subrequests.Maxim Dounin2-6/+11
Much like in limit_req, use the wev->delayed flag to ensure proper handling and interoperability with limit_rate.
2017-04-02Limit req: fixed delaying subrequests.Maxim Dounin1-1/+4
Since limit_req uses connection's write event to delay request processing, it can conflict with timers in other subrequests. In particular, even if applied to an active subrequest, it can break things if wev->delayed is already set (due to limit_rate or sendfile_max_chunk), since after limit_req finishes the wev->delayed flag will be set and no timer will be active. Fix is to use the wev->delayed flag in limit_req as well. This ensures that wev->delayed won't be set after limit_req finishes, and also ensures that limit_req's timers will be properly handled by other subrequests if the one delayed by limit_req is not active.
2017-03-26HTTP/2: style and typos.Piotr Sikora2-7/+8
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2017-03-29HTTP/2: fixed connection finalization.Valentin Bartenev1-3/+8
All streams in connection must be finalized before the connection itself can be finalized and all related memory is freed. That's not always possible on the current event loop iteration. Thus when the last stream is finalized, it sets the special read event handler ngx_http_v2_handle_connection_handler() and posts the event. Previously, this handler didn't check the connection state and could call the regular event handler on a connection that was already in finalization stage. In the worst case that could lead to a segmentation fault, since some data structures aren't supposed to be used during connection finalization. Particularly, the waiting queue can contain already freed streams, so the WINDOW_UPDATE frame received by that moment could trigger accessing to these freed streams. Now, the connection error flag is explicitly checked in ngx_http_v2_handle_connection_handler().
2017-03-29HTTP/2: fixed stream finalization.Valentin Bartenev1-0/+3
In order to finalize stream the error flag is set on fake connection and either "write" or "read" event handler is called. The read events of fake connections are always ready, but it's not the case with the write events. When the ready flag isn't set, the error flag can be not checked in some cases and as a result stream isn't finalized. Now the ready flag is explicilty set on write events for proper finalization in all cases.
2017-03-26HTTP/2: emit PROTOCOL_ERROR on padding errors.Piotr Sikora1-2/+4
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2017-03-26HTTP/2: fix flow control with padded DATA frames.Piotr Sikora1-10/+12
Previously, flow control didn't account for padding in DATA frames, which meant that its view of the world could drift from peer's view by up to 256 bytes per received padded DATA frame, which could lead to a deadlock. Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2017-03-26HTTP/2: fix $body_bytes_sent variable.Piotr Sikora1-0/+3
Previously, its value included payloads and frame headers of HEADERS and CONTINUATION frames. Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2017-03-26HTTP/2: fix $bytes_sent variable.Piotr Sikora1-0/+2
Previously, its value accounted for payloads of HEADERS, CONTINUATION and DATA frames, as well as frame headers of HEADERS and DATA frames, but it didn't account for frame headers of CONTINUATION frames. Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2017-03-28Copy filter: wake up subrequests after aio operations.Maxim Dounin1-2/+30
Previously, connection write handler was called, resulting in wake up of the active subrequest. This change makes it possible to read data in non-active subrequests as well. For example, this allows SSI to process instructions in non-active subrequests earlier and start additional subrequests if needed, reducing overall response time.
2017-03-28Threads: fixed request hang with aio_write and subrequests.Maxim Dounin1-2/+12
If the subrequest is already finalized, the handler set with aio_write may still be used by sendfile in threads when using range requests (see also e4c1f5b32868, and the original note in 9fd738b85fad). Calling already finalized subrequest's r->write_event_handler in practice results in request hang in some cases. Fix is to trigger connection event handler if the subrequest was already finalized.
2017-03-28Simplified and improved sendfile() code on Linux.Maxim Dounin1-67/+47
The ngx_linux_sendfile() function is now used for both normal sendfile() and sendfile in threads. The ngx_linux_sendfile_thread() function was modified to use the same interface as ngx_linux_sendfile(), and is simply called from ngx_linux_sendfile() when threads are enabled. Special return code NGX_DONE is used to indicate that a thread task was posted and no further actions are needed. If number of bytes sent is less that what we were sending, we now always retry sending. This is needed for sendfile() in threads as the number of bytes we are sending might have been changed since the thread task was posted. And this is also needed for Linux 4.3+, as sendfile() might be interrupted at any time and provides no indication if it was interrupted or not (ticket #1174).
2017-03-28Fixed ngx_open_cached_file() error handling.Sergey Kandaurov5-3/+24
If of.err is 0, it means that there was a memory allocation error and no further logging and/or processing is needed. The of.failed string can be only accessed if of.err is not 0.
2017-03-28Core: set nginx_shared_zone name via ngx_str_set().Ruslan Ermilov1-2/+1
2017-03-28Use ngx_array_init() to initialize arrays.Ruslan Ermilov1-19/+15
2017-03-28Version bump.Ruslan Ermilov1-2/+2
2017-03-24Fixed CPU hog while freeing hc->busy after e662cbf1b932 (1.11.11).Maxim Dounin1-0/+1
Reported by Richard Stanway, http://mailman.nginx.org/pipermail/nginx/2017-March/053296.html.
2017-03-22Simplified code about duplicate root/alias directive.Ruslan Ermilov1-8/+6
2017-03-22Unified error messages about duplicate directives.Ruslan Ermilov3-3/+3
2017-03-22Version bump.Ruslan Ermilov1-2/+2
2017-03-17Fixed a comment.Ruslan Ermilov1-1/+1
2017-03-16Added missing "static" specifier found by gcc -Wtraditional.Ruslan Ermilov1-1/+1
This has somehow escaped from fbdaad9b0e7b.
2017-03-07Style.Maxim Dounin1-2/+0
2017-03-07Introduced worker_shutdown_timeout.Maxim Dounin5-0/+66
The directive configures a timeout to be used when gracefully shutting down worker processes. When the timer expires, nginx will try to close all the connections currently open to facilitate shutdown.
2017-03-07Cancelable timers are now preserved if there are other timers.Maxim Dounin4-36/+17
There is no need to cancel timers early if there are other timers blocking shutdown anyway. Preserving such timers allows nginx to continue some periodic work till the shutdown is actually possible. With the new approach, timers with ev->cancelable are simply ignored when checking if there are any timers left during shutdown.
2017-03-07Core: introduced ngx_rbtree_next().Maxim Dounin2-0/+31
2017-03-07Access log: removed dead ev->timedout check in flush timer handler.Maxim Dounin2-28/+2
The ev->timedout flag is set on first timer expiration, and never reset after it. Due to this the code to stop the timer when the timer was canceled never worked (except in a very specific time frame immediately after start), and the timer was always armed again. This essentially resulted in a buffer flush at the end of an event loop iteration. This behaviour actually seems to be better than just stopping the flush timer for the whole shutdown, so it is preserved as is instead of fixing the code to actually remove the timer. It will be further improved by upcoming changes to preserve cancelable timers if there are other timers blocking shutdown.
2017-03-07Converted hc->busy/hc->free to use chain links.Maxim Dounin2-39/+53
Most notably, this fixes possible buffer overflows if number of large client header buffers in a virtual server is different from the one in the default server. Reported by Daniil Bondarev.
2017-03-07Removed casts not needed after 1f513d7f1b45.Ruslan Ermilov1-2/+2
2017-03-06Mail: don't emit separator in capability lists for APOP.Sergey Kandaurov1-0/+16
Notably, this fixes CAPA and AUTH output. The bug had appeared in nginx 1.11.6 (73b451d304c0).
2017-03-06Added missing "static" specifiers found by gcc -Wtraditional.Ruslan Ermilov3-3/+3
2017-03-02Added missing static specifiers.Eran Kornblau15-35/+35
2017-02-27Fixed background update with "if".Maxim Dounin1-0/+1
Cloned subrequests should inherit r->content_handler. This way they will be able to use the same location configuration as the original request if there are "if" directives in the configuration. Without r->content_handler inherited, the following configuration tries to access a static file in the update request: location / { set $true 1; if ($true) { # nothing } proxy_pass http://backend; proxy_cache one; proxy_cache_use_stale updating; proxy_cache_background_update on; } See http://mailman.nginx.org/pipermail/nginx/2017-February/053019.html for initial report.
2017-02-17Fixed ngx_parse_size() / ngx_parse_offset() with 0-length strings.Maxim Dounin1-0/+10
2017-02-16Version bump.Maxim Dounin1-2/+2
2017-02-13Gzip: free chain links on the hot path (ticket #1046).Maxim Dounin1-6/+16