summaryrefslogtreecommitdiffhomepage
path: root/src (follow)
AgeCommit message (Collapse)AuthorFilesLines
2017-04-24HTTP/2: reduced difference to HTTP/1.x in reading request body.Valentin Bartenev3-33/+18
Particularly, this eliminates difference in behavior for requests without body and deduplicates code. Prodded by Piotr Sikora.
2017-04-24HTTP/2: rejecting zero WINDOW_UPDATE with PROTOCOL_ERROR.Valentin Bartenev1-0/+38
It's required by RFC 7540. While there is no real harm from such frames, that should help to detect broken clients. Based on a patch by Piotr Sikora.
2017-04-20Gzip static: use an appropriate error on memory allocation failure.Sergey Kandaurov1-1/+1
2017-04-20Cleaned up r->headers_out.headers allocation error handling.Sergey Kandaurov8-15/+28
If initialization of a header failed for some reason after ngx_list_push(), leaving the header as is can result in uninitialized memory access by the header filter or the log module. The fix is to clear partially initialized headers in case of errors. For the Cache-Control header, the fix is to postpone pushing r->headers_out.cache_control until its value is completed.
2017-04-20Core: signal sender pid logging.Igor Sysoev1-8/+24
2017-04-18Sub filter: restored ngx_http_set_ctx() at the proper place.Sergey Kandaurov1-2/+2
Previously, ngx_http_sub_header_filter() could fail with a partially initialized context, later accessed in ngx_http_sub_body_filter() if called from the perl content handler. The issue had appeared in 2c045e5b8291 (1.9.4). A better fix would be to handle ngx_http_send_header() errors in the perl module, though this doesn't seem to be easy enough.
2017-04-18SSL: compatibility with OpenSSL master branch.Sergey Kandaurov1-1/+1
The SSL_CTRL_SET_CURVES_LIST macro is removed in the OpenSSL master branch. SSL_CTX_set1_curves_list is preserved as compatibility with previous versions.
2017-04-18SSL: disabled renegotiation detection in client mode.Sergey Kandaurov2-1/+8
CVE-2009-3555 is no longer relevant and mitigated by the renegotiation info extension (secure renegotiation). On the other hand, unexpected renegotiation still introduces potential security risks, and hence we do not allow renegotiation on the server side, as we never request renegotiation. On the client side the situation is different though. There are backends which explicitly request renegotiation, and disabled renegotiation introduces interoperability problems. This change allows renegotiation on the client side, and fixes interoperability problems as observed with such backends (ticket #872). Additionally, with TLSv1.3 the SSL_CB_HANDSHAKE_START flag is currently set by OpenSSL when receiving a NewSessionTicket message, and was detected by nginx as a renegotiation attempt. This looks like a bug in OpenSSL, though this change also allows better interoperability till the problem is fixed.
2017-04-18SSL: added support for TLSv1.3 in ssl_protocols directive.Sergey Kandaurov8-0/+13
Support for the TLSv1.3 protocol will be introduced in OpenSSL 1.1.1.
2017-04-11Set UDP datagram source address (ticket #1239).Roman Arutyunyan1-0/+90
Previously, the source IP address of a response UDP datagram could differ from the original datagram destination address. This could happen if the server UDP socket is bound to a wildcard address and the network interface chosen to output the response packet has a different default address than the destination address of the original packet. For example, if two addresses from the same network are configured on an interface. Now source address is set explicitly if a response is sent for a server UDP socket bound to a wildcard address.
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