summaryrefslogtreecommitdiffhomepage
path: root/src (follow)
AgeCommit message (Collapse)AuthorFilesLines
2015-12-17Resolver: improved PTR response processing.Ruslan Ermilov1-28/+74
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.
2015-12-17Resolver: style.Ruslan Ermilov1-13/+13
Renamed argument in ngx_resolver_process_a() for consistency.
2016-02-02Resolver: free TCP buffers on resolver cleanup.Roman Arutyunyan1-0/+10
2016-02-02Resolver: fixed possible resource leak introduced in 5a16d40c63de.Ruslan Ermilov1-0/+2
Found by Coverity (CID 1351175).
2016-01-28Resolver: TCP support.Roman Arutyunyan2-51/+549
Resend DNS query over TCP once UDP response came truncated.
2016-01-28Resolver: per-request DNS server balancer.Roman Arutyunyan2-5/+17
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.
2016-01-28Resolver: renamed UDP-specific structures, fields and variables.Roman Arutyunyan2-63/+63
They will be used for TCP connections as well.
2016-01-28Resolver: removed unused field from ngx_resolver_ctx_t.Roman Arutyunyan1-3/+1
2016-01-28Version bump.Roman Arutyunyan1-2/+2
2016-01-26Resolver: limited CNAME recursion.Ruslan Ermilov1-6/+22
Previously, the recursion was only limited for cached responses.
2016-01-26Resolver: fixed use-after-free memory accesses with CNAME.Roman Arutyunyan2-39/+35
When several requests were waiting for a response, then after getting a CNAME response only the last request's context had the name updated. Contexts of other requests had the wrong name. This name was used by ngx_resolve_name_done() to find the node to remove the request context from. When the name was wrong, the request could not be properly cancelled, its context was freed but stayed linked to the node's waiting list. This happened e.g. when the first request was aborted or timed out before the resolving completed. When it completed, this triggered a use-after-free memory access by calling ctx->handler of already freed request context. The bug manifests itself by "could not cancel <name> resolving" alerts in error_log. When a request was responded with a CNAME, the request context kept the pointer to the original node's rn->u.cname. If the original node expired before the resolving timed out or completed with an error, this would trigger a use-after-free memory access via ctx->name in ctx->handler(). The fix is to keep ctx->name unmodified. The name from context is no longer used by ngx_resolve_name_done(). Instead, we now keep the pointer to resolver node to which this request is linked. Keeping the original name intact also improves logging.
2016-01-26Resolver: changed the ngx_resolver_create_*_query() arguments.Roman Arutyunyan1-30/+27
No functional changes. This is needed by the following change.
2016-01-26Resolver: fixed CNAME processing for several requests.Ruslan Ermilov1-6/+15
When several requests were waiting for a response, then after getting a CNAME response only the last request was properly processed, while others were left waiting.
2016-01-26Resolver: fixed crashes in timeout handler.Ruslan Ermilov2-25/+42
If one or more requests were waiting for a response, then after getting a CNAME response, the timeout event on the first request remained active, pointing to the wrong node with an empty rn->waiting list, and that could cause either null pointer dereference or use-after-free memory access if this timeout expired. If several requests were waiting for a response, and the first request terminated (e.g., due to client closing a connection), other requests were left without a timeout and could potentially wait indefinitely. This is fixed by introducing per-request independent timeouts. This change also reverts 954867a2f0a6 and 5004210e8c78.
2016-01-26Resolver: fixed possible segmentation fault on DNS format error.Roman Arutyunyan1-1/+1
2016-01-12Request body: removed surplus assigment, no functional changes.Valentin Bartenev1-6/+0
Setting rb->bufs to NULL is surplus after ngx_http_write_request_body() has returned NGX_OK.
2016-01-11Core: worker_cpu_affinity auto.Maxim Dounin2-2/+42
If enabled, workers are bound to available CPUs, each worker to once CPU in order. If there are more workers than available CPUs, remaining are bound in a loop, starting again from the first available CPU. The optional mask parameter defines which CPUs are available for automatic binding. In collaboration with Vladimir Homutov.
2016-01-11Upstream: fixed changing method on X-Accel-Redirect.Maxim Dounin1-0/+1
Previously, only r->method was changed, resulting in handling of a request as GET within nginx itself, but not in requests to proxied servers. See http://mailman.nginx.org/pipermail/nginx/2015-December/049518.html.
2015-12-17Upstream: don't keep connections on early responses (ticket #669).Maxim Dounin3-0/+8
2015-12-17Fixed PROXY protocol on IPv6 sockets (ticket #858).Maxim Dounin1-0/+1
2015-12-17Version bump.Maxim Dounin1-2/+2
2015-12-09Fixed fastcgi_pass with UNIX socket and variables (ticket #855).Ruslan Ermilov1-1/+3
This was broken in a93345ee8f52 (1.9.8).
2015-12-09Version bump.Ruslan Ermilov1-2/+2
2015-12-08Slice filter: terminate first slice with last_in_chain flag.Roman Arutyunyan1-0/+1
This flag makes sub filter flush buffered data and optimizes allocation in copy filter.
2015-12-08Slice filter: never run subrequests when main request is buffered.Roman Arutyunyan1-0/+4
With main request buffered, it's possible, that a slice subrequest will send output before it. For example, while main request is waiting for aio read to complete, a slice subrequest can start an aio operation as well. The order in which aio callbacks are called is undetermined.
2015-12-08SSL: fixed possible segfault on renegotiation (ticket #845).Sergey Kandaurov1-0/+4
Skip SSL_CTX_set_tlsext_servername_callback in case of renegotiation. Do nothing in SNI callback as in this case it will be supplied with request in c->data which isn't expected and doesn't work this way. This was broken by b40af2fd1c16 (1.9.6) with OpenSSL master branch and LibreSSL.
2015-12-07Slice filter.Roman Arutyunyan3-5/+546
Splits a request into subrequests, each providing a specific range of response. The variable "$slice_range" must be used to set subrequest range and proper cache key. The directive "slice" sets slice size. The following example splits requests into 1-megabyte cacheable subrequests. server { listen 8000; location / { slice 1m; proxy_cache cache; proxy_cache_key $uri$is_args$args$slice_range; proxy_set_header Range $slice_range; proxy_cache_valid 200 206 1h; proxy_pass http://127.0.0.1:9000; } }
2015-12-07Upstream: fill r->headers_out.content_range from upstream response.Roman Arutyunyan1-0/+5
2015-12-02Core: fix typo in error message.Piotr Sikora1-1/+1
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2015-12-03Style: NGX_PTR_SIZE replaced with sizeof(void *).Maxim Dounin2-2/+2
The NGX_PTR_SIZE macro is only needed in preprocessor directives where it's not possible to use sizeof().
2015-12-02Style.Maxim Dounin1-1/+1
2015-11-30Stop emulating a space character after r->method_name.Ruslan Ermilov2-4/+1
This is an API change. The proxy module was modified to not depend on this in 44122bddd9a1. No known third-party modules seem to depend on this.
2015-11-06Proxy: improved code readability.Ruslan Ermilov1-12/+5
Do not assume that space character follows the method name, just pass it explicitly. The fuss around it has already proved to be unsafe, see bbdb172f0927 and http://mailman.nginx.org/pipermail/nginx-ru/2013-January/049692.html for details.
2015-11-30Reduced the number of GET method constants.Ruslan Ermilov1-4/+1
2015-11-30Increased the default "connection_pool_size" on 64-bit platforms.Valentin Bartenev1-1/+1
The previous default of 256 bytes isn't enough and results in two allocations on each accepted connection, which is suboptimal.
2015-11-06Style: unified request method checks.Ruslan Ermilov5-5/+5
2015-11-23Core: enabled "include" inside http upstreams (ticket #635).Ruslan Ermilov1-1/+1
The directive already works inside stream upstream blocks.
2015-11-21Upstream: fixed "no port" detection in evaluated upstreams.Ruslan Ermilov5-10/+22
If an upstream with variables evaluated to address without a port, then instead of a "no port in upstream" error an attempt was made to connect() which failed with EADDRNOTAVAIL.
2015-11-17Used the pwritev() syscall for writing files where possible.Valentin Bartenev1-3/+35
It is more effective, because it doesn't require a separate lseek().
2015-11-17Moved file writev() handling code to a separate function.Valentin Bartenev1-32/+51
No functional changes.
2015-11-17Handled EINTR from write() and pwrite() syscalls.Valentin Bartenev1-3/+20
This is in addition to 6fce16b1fc10.
2015-11-17Adjusted file->sys_offset after the write() syscall.Valentin Bartenev1-0/+1
This fixes suboptimal behavior caused by surplus lseek() for sequential writes on systems without pwrite(). A consecutive read after write might result in an error on systems without pread() and pwrite(). Fortunately, at the moment there are no widely used systems without these syscalls.
2015-11-17Version bump.Valentin Bartenev1-2/+2
2015-11-16Realip: the $realip_remote_addr variable.Ruslan Ermilov1-1/+71
2015-11-13HTTP/2: reused HEADERS and CONTINUATION frames buffers.Valentin Bartenev2-10/+21
2015-11-13HTTP/2: fixed handling of output HEADERS frames.Valentin Bartenev1-6/+19
The HEADERS frame is always represented by more than one buffer since b930e598a199, but the handling code hasn't been adjusted. Only the first buffer of HEADERS frame was checked and if it had been sent while others had not, the rest of the frame was dropped, resulting in broken connection. Before b930e598a199, the problem could only be seen in case of HEADERS frame with CONTINUATION.
2015-11-13HTTP/2: fixed invalid headers handling (ticket #831).Valentin Bartenev1-0/+2
The r->invalid_header flag wasn't reset once an invalid header appeared in a request, resulting in all subsequent headers in the request were also marked as invalid.
2015-11-11Upstream: proxy_cache_convert_head directive.Roman Arutyunyan3-1/+13
The directive toggles conversion of HEAD to GET for cacheable proxy requests. When disabled, $request_method must be added to cache key for consistency. By default, HEAD is converted to GET as before.
2015-11-05SSL: only select HTTP/2 using NPN if "http2" is enabled.Valentin Bartenev1-10/+16
OpenSSL doesn't check if the negotiated protocol has been announced. As a result, the client might force using HTTP/2 even if it wasn't enabled in configuration.
2015-11-05HTTP/2: backed out 16905ecbb49e (ticket #822).Valentin Bartenev1-3/+5
It caused inconsistency between setting "in_closed" flag and the moment when the last DATA frame was actually read. As a result, the body buffer might not be initialized properly in ngx_http_v2_init_request_body(), which led to a segmentation fault in ngx_http_v2_state_read_data(). Also it might cause start processing of incomplete body. This issue could be triggered when the processing of a request was delayed, e.g. in the limit_req or auth_request modules.