summaryrefslogtreecommitdiffhomepage
path: root/src/core (follow)
AgeCommit message (Collapse)AuthorFilesLines
2023-05-19Merged with the quic branch.Roman Arutyunyan6-0/+279
2023-05-14Common tree insert function for QUIC and UDP connections.Roman Arutyunyan1-0/+4
Previously, ngx_udp_rbtree_insert_value() was used for plain UDP and ngx_quic_rbtree_insert_value() was used for QUIC. Because of this it was impossible to initialize connection tree in ngx_create_listening() since this function is not aware what kind of listening it creates. Now ngx_udp_rbtree_insert_value() is used for both QUIC and UDP. To make is possible, a generic key field is added to ngx_udp_connection_t. It keeps client address for UDP and connection ID for QUIC.
2023-05-06QUIC: disabled datagram fragmentation.Roman Arutyunyan1-0/+72
As per RFC 9000, Section 14: UDP datagrams MUST NOT be fragmented at the IP layer.
2023-04-18Fixed segfault if regex studies list allocation fails.Maxim Dounin1-3/+3
The rcf->studies list is unconditionally accessed by ngx_regex_cleanup(), and this used to cause NULL pointer dereference if allocation failed. Fix is to set cleanup handler only when allocation succeeds.
2023-04-17Version bump.Sergey Kandaurov1-2/+2
2023-03-29Merged with the default branch.Sergey Kandaurov4-19/+63
2023-03-10Syslog: introduced error log handler.Maxim Dounin2-9/+41
This ensures that errors which happen during logging to syslog are logged with proper context, such as "while logging to syslog" and the server name. Prodded by Safar Safarly.
2023-03-10Syslog: removed usage of ngx_cycle->log and ngx_cycle->hostname.Maxim Dounin2-18/+24
During initial startup the ngx_cycle->hostname is not available, and previously this resulted in incorrect logging. Instead, hostname from the configuration being parsed is now preserved in the syslog peer structure and then used during logging. Similarly, ngx_cycle->log might not match the configuration where the syslog peer is defined if the configuration is not yet fully applied, and previously this resulted in unexpected logging of syslog errors and debug information. Instead, cf->cycle->new_log is now referenced in the syslog peer structure and used for logging, similarly to how it is done in other modules.
2023-02-23Core: stricter UTF-8 handling in ngx_utf8_decode().Yugo Horie1-1/+6
An UTF-8 octet sequence cannot start with a 11111xxx byte (above 0xf8), see https://datatracker.ietf.org/doc/html/rfc3629#section-3. Previously, such bytes were accepted by ngx_utf8_decode() and misinterpreted as 11110xxx bytes (as in a 4-byte sequence). While unlikely, this can potentially cause issues. Fix is to explicitly reject such bytes in ngx_utf8_decode().
2023-02-02Lingering close for connections with pipelined requests.Maxim Dounin1-0/+1
This is expected to help with clients using pipelining with some constant depth, such as apt[1][2]. When downloading many resources, apt uses pipelining with some constant depth, a number of requests in flight. This essentially means that after receiving a response it sends an additional request to the server, and this can result in requests arriving to the server at any time. Further, additional requests are sent one-by-one, and can be easily seen as such (neither as pipelined, nor followed by pipelined requests). The only safe approach to close such connections (for example, when keepalive_requests is reached) is with lingering. To do so, now nginx monitors if pipelining was used on the connection, and if it was, closes the connection with lingering. [1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=973861#10 [2] https://mailman.nginx.org/pipermail/nginx-devel/2023-January/ZA2SP5SJU55LHEBCJMFDB2AZVELRLTHI.html
2023-01-02Merged with the default branch.Sergey Kandaurov3-5/+5
2022-12-21Updated link to OpenVZ suspend/resume bug.Maxim Dounin1-1/+1
2022-12-16Style.BullerDu1-2/+2
2022-12-16Version bump.Sergey Kandaurov1-2/+2
2022-12-15Merged with the default branch.Sergey Kandaurov4-12/+15
2022-11-30Removed casts from ngx_memcmp() macro.Maxim Dounin1-1/+1
Casts are believed to be not needed, since memcmp() has "const void *" arguments since introduction of the "void" type in C89. And on pre-C89 platforms nginx is unlikely to compile without warnings anyway, as there are no casts in memcpy() and memmove() calls. These casts were added in 1648:89a47f19b9ec without any details on why they were added, and Igor does not remember details either. The most plausible explanation is that they were copied from ngx_strcmp() and were not really needed even at that time. Prodded by Alejandro Colomar.
2022-11-30Fixed alignment of ngx_memmove()/ngx_movemem() macro definitions.Maxim Dounin1-2/+2
2022-11-08Fixed PROXY protocol to use ngx_memcpy()/ngx_memcmp().Maxim Dounin1-5/+5
2022-11-08Added logging to PROXY protocol write buffer check.Maxim Dounin1-0/+2
The check is not expected to fail unless there is a bug in the calling code. But given the check is here, it should log an alert if it fails instead of silently closing the connection.
2022-11-02Increased maximum read PROXY protocol header size.Roman Arutyunyan2-2/+3
Maximum size for reading the PROXY protocol header is increased to 4096 to accommodate a bigger number of TLVs, which are supported since cca4c8a715de. Maximum size for writing the PROXY protocol header is not changed since only version 1 is currently supported.
2022-11-03Version bump.Roman Arutyunyan1-2/+2
2022-09-27Added type cast to ngx_proxy_protocol_parse_uint16().Roman Arutyunyan1-1/+3
The cast is added to make ngx_proxy_protocol_parse_uint16() similar to ngx_proxy_protocol_parse_uint32().
2022-10-12PROXY protocol v2 TLV variables.Roman Arutyunyan2-2/+187
The variables have prefix $proxy_protocol_tlv_ and are accessible by name and by type. Examples are: $proxy_protocol_tlv_0x01, $proxy_protocol_tlv_alpn.
2022-10-10Log only the first line of user input on PROXY protocol v1 error.Roman Arutyunyan1-1/+7
Previously, all received user input was logged. If a multi-line text was received from client and logged, it could reduce log readability and also make it harder to parse nginx log by scripts. The change brings to PROXY protocol the same behavior that exists for HTTP request line in ngx_http_log_error_handler().
2022-10-20Merged with the default branch.Sergey Kandaurov3-6/+199
2022-08-30Version bump.Maxim Dounin1-2/+2
2022-07-14Resolver: fixed memory leak for the "ipv4=off" case.Sergey Kandaurov1-4/+1
This change partially reverts 2a77754cd9fe to properly free rn->query. Found by Coverity (CID 1507244).
2022-07-12The "ipv4=" parameter of the "resolver" directive.Ruslan Ermilov2-15/+54
When set to "off", only IPv6 addresses will be resolved, and no A queries are ever sent (ticket #2196).
2022-06-29Version bump.Maxim Dounin1-2/+2
2022-06-01Resolver: make TCP write timer event cancelable.Aleksei Bavshin1-0/+1
Similar to 70e65bf8dfd7, the change is made to ensure that the ability to cancel resolver tasks is fully controlled by the caller. As mentioned in the referenced commit, it is safe to make this timer cancelable because resolve tasks can have their own timeouts that are not cancelable. The scenario where this may become a problem is a periodic background resolve task (not tied to a specific request or a client connection), which receives a response with short TTL, large enough to warrant fallback to a TCP query. With each event loop wakeup, we either have a previously set write timer instance or schedule a new one. The non-cancelable write timer can delay or block graceful shutdown of a worker even if the ngx_resolver_ctx_t->cancelable flag is set by the API user, and there are no other tasks or connections. We use the resolver API in this way to maintain the list of upstream server addresses specified with the 'resolve' parameter, and there could be third-party modules implementing similar logic.
2022-07-26Merged with the default branch.Sergey Kandaurov3-16/+52
2022-06-22Merged with the default branch.Sergey Kandaurov3-4/+8
2022-05-30FastCGI: combining headers with identical names (ticket #1724).Maxim Dounin1-2/+5
FastCGI responder is expected to receive CGI/1.1 environment variables in the parameters (see section "6.2 Responder" of the FastCGI specification). Obviously enough, there cannot be multiple environment variables with the same name. Further, CGI specification (RFC 3875, section "4.1.18. Protocol-Specific Meta-Variables") explicitly requires to combine headers: "If multiple header fields with the same field-name are received then the server MUST rewrite them as a single value having the same semantics".
2022-05-30Version bump.Maxim Dounin1-2/+2
2022-04-20QUIC: separate UDP framework for QUIC.Roman Arutyunyan1-4/+0
Previously, QUIC used the existing UDP framework, which was created for UDP in Stream. However the way QUIC connections are created and looked up is different from the way UDP connections in Stream are created and looked up. Now these two implementations are decoupled.
2022-02-14Merged with the default branch.Sergey Kandaurov2-2/+3
2022-02-03HTTP/2: made it possible to flush response headers (ticket #1743).Maxim Dounin1-0/+1
Response headers can be buffered in the SSL buffer. But stream's fake connection buffered flag did not reflect this, so any attempts to flush the buffer without sending additional data were stopped by the write filter. It does not seem to be possible to reflect this in fc->buffered though, as we never known if main connection's c->buffered corresponds to the particular stream or not. As such, fc->buffered might prevent request finalization due to sending data on some other stream. Fix is to implement handling of flush buffers when the c->need_flush_buf flag is set, similarly to the existing last buffer handling. The same flag is now used for UDP sockets in the stream module instead of explicit checking of c->type.
2022-01-27Version bump.Vladimir Homutov1-2/+2
2022-01-25Merged with the default branch.Sergey Kandaurov2-17/+5
2022-01-19Core: simplify reader lock release.Pavel Pautov1-15/+3
2021-12-29Version bump.Maxim Dounin1-2/+2
2021-12-29Merged with the default branch.Sergey Kandaurov6-102/+462
2021-12-27Support for sendfile(SF_NOCACHE).Maxim Dounin1-4/+13
The SF_NOCACHE flag, introduced in FreeBSD 11 along with the new non-blocking sendfile() implementation by glebius@, makes it possible to use sendfile() along with the "directio" directive.
2021-12-27Simplified sendfile(SF_NODISKIO) usage.Maxim Dounin4-37/+2
Starting with FreeBSD 11, there is no need to use AIO operations to preload data into cache for sendfile(SF_NODISKIO) to work. Instead, sendfile() handles non-blocking loading data from disk by itself. It still can, however, return EBUSY if a page is already being loaded (for example, by a different process). If this happens, we now post an event for the next event loop iteration, so sendfile() is retried "after a short period", as manpage recommends. The limit of the number of EBUSY tolerated without any progress is preserved, but now it does not result in an alert, since on an idle system event loop iteration might be very short and EBUSY can happen many times in a row. Instead, SF_NODISKIO is simply disabled for one call once the limit is reached. With this change, sendfile(SF_NODISKIO) is now used automatically as long as sendfile() is enabled, and no longer requires "aio on;".
2021-12-25Core: added NGX_REGEX_MULTILINE for 3rd party modules.Maxim Dounin2-2/+11
Notably, NAXSI is known to misuse ngx_regex_compile() with rc.options set to PCRE_CASELESS | PCRE_MULTILINE. With PCRE2 support, and notably binary compatibility changes, it is no longer possible to set PCRE[2]_MULTILINE option without using proper interface. To facilitate correct usage, this change adds the NGX_REGEX_MULTILINE option.
2021-12-25PCRE2 and PCRE binary compatibility.Maxim Dounin2-15/+48
With this change, dynamic modules using nginx regex interface can be used regardless of the variant of the PCRE library nginx was compiled with. If a module is compiled with different PCRE library variant, in case of ngx_regex_exec() errors it will report wrong function name in error messages. This is believed to be tolerable, given that fixing this will require interface changes.
2021-12-25PCRE2 library support.Maxim Dounin2-10/+351
The PCRE2 library is now used by default if found, instead of the original PCRE library. If needed for some reason, this can be disabled with the --without-pcre2 configure option. To make it possible to specify paths to the library and include files via --with-cc-opt / --with-ld-opt, the library is first tested without any additional paths and options. If this fails, the pcre2-config script is used. Similarly to the original PCRE library, it is now possible to build PCRE2 from sources with nginx configure, by using the --with-pcre= option. It automatically detects if PCRE or PCRE2 sources are provided. Note that compiling PCRE2 10.33 and later requires inttypes.h. When compiling on Windows with MSVC, inttypes.h is only available starting with MSVC 2013. In older versions some replacement needs to be provided ("echo '#include <stdint.h>' > pcre2-10.xx/src/inttypes.h" is good enough for MSVC 2010). The interface on nginx side remains unchanged.
2021-12-25Core: ngx_regex.c style cleanup.Maxim Dounin1-17/+17
Notably, ngx_pcre_pool and ngx_pcre_studies are renamed to ngx_regex_pool and ngx_regex_studies, respectively.
2021-12-25Core: fixed ngx_pcre_studies cleanup.Maxim Dounin1-40/+43
If a configuration parsing fails for some reason, ngx_regex_module_init() is not called, and ngx_pcre_studies remained set despite the fact that the pool it was allocated from is already freed. This might result in a segmentation fault during runtime regular expression compilation, such as in SSI, for example, in the single process mode, or if a worker process died and was respawned from a master process in such an inconsistent state. Fix is to clear ngx_pcre_studies from the pool cleanup handler (which is anyway used to free JIT-compiled patterns).
2021-12-24Merged with the default branch.Ruslan Ermilov1-2/+2