summaryrefslogtreecommitdiffhomepage
path: root/src/core (follow)
AgeCommit message (Collapse)AuthorFilesLines
2025-04-18Core: improved NGX_ALIGNMENT detection on some x86_64 platforms.Aleksei Bavshin1-1/+1
Previously, the default pool alignment used sizeof(unsigned long), with the expectation that this would match to a platform word size. Certain 64-bit platforms prove this assumption wrong by keeping the 32-bit long type, which is fully compliant with the C standard. This introduces a possibility of suboptimal misaligned access to the data allocated with ngx_palloc() on the affected platforms, which is addressed here by changing the default NGX_ALIGNMENT to a pointer size. As we override the detection in auto/os/conf for all the machine types except x86, and Unix-like 64-bit systems prefer the 64-bit long, the impact of the change should be limited to Win64 x64.
2025-04-16Version bump.Roman Arutyunyan1-2/+2
2025-02-18Version bump.Sergey Kandaurov1-2/+2
2025-01-23Upstream: fixed --with-compat build without SSL, broken by 454ad0e.Pavel Pautov1-0/+1
2024-11-27Version bump.Roman Arutyunyan1-2/+2
2024-11-26Realip: allowed square brackets with portless IPv6 address.Roman Arutyunyan1-1/+5
When client address is received, IPv6 address could be specified without square brackets and without port, as well as both with the brackets and port. The change allows IPv6 in square brackets and no port, which was previously considered an error. This format conforms to RFC 3986. The change also affects proxy_bind and friends.
2024-11-07Core: inheritance of non-reusable shared memory zones.Ruslan Ermilov1-4/+10
When re-creating a non-reusable zone, make the pointer to the old zone available during the new zone initialization.
2024-10-08Version bump.Sergey Kandaurov1-2/+2
2024-08-20Version bump.Sergey Kandaurov1-2/+2
2024-08-09Version bump.Sergey Kandaurov1-2/+2
2024-05-23Optimized chain link usage (ticket #2614).Roman Arutyunyan1-2/+8
Previously chain links could sometimes be dropped instead of being reused, which could result in increased memory consumption during long requests. A similar chain link issue in ngx_http_gzip_filter_module was fixed in da46bfc484ef (1.11.10). Based on a patch by Sangmin Lee.
2024-05-03Version bump.Sergey Kandaurov1-2/+2
2024-03-18Fixed undefined behaviour with IPv4-mapped IPv6 addresses.Sergey Kandaurov1-1/+1
Previously, it could result when left-shifting signed integer due to implicit integer promotion, such that the most significant bit appeared on the sign bit. In practice, though, this results in the same left value as with an explicit cast, at least on known compilers, such as GCC and Clang. The reason is that in_addr_t, which is equivalent to uint32_t and same as "unsigned int" in ILP32 and LP64 data type models, has the same type width as the intermediate after integer promotion, so there's no side effects such as sign-extension. This explains why adding an explicit cast does not change object files in practice. Found with UndefinedBehaviorSanitizer (shift). Based on a patch by Piotr Sikora.
2024-03-21Version bump.Roman Arutyunyan1-2/+2
2023-10-27Version bump.Sergey Kandaurov1-2/+2
2023-10-18Core: changed ngx_queue_sort() to use merge sort.Maxim Dounin2-13/+42
This improves nginx startup times significantly when using very large number of locations due to computational complexity of the sorting algorithm being used: insertion sort is O(n*n) on average, while merge sort is O(n*log(n)). In particular, in a test configuration with 20k locations total startup time is reduced from 8 seconds to 0.9 seconds. Prodded by Yusuke Nojima, https://mailman.nginx.org/pipermail/nginx-devel/2023-September/NUL3Y2FPPFSHMPTFTL65KXSXNTX3NQMK.html
2023-10-17Core: fixed memory leak on configuration reload with PCRE2.Maxim Dounin1-3/+4
In ngx_regex_cleanup() allocator wasn't configured when calling pcre2_compile_context_free() and pcre2_match_data_free(), resulting in no ngx_free() call and leaked memory. Fix is ensure that allocator is configured for global allocations, so that ngx_free() is actually called to free memory. Additionally, ngx_regex_compile_context was cleared in ngx_regex_module_init(). It should be either not cleared, so it will be freed by ngx_regex_cleanup(), or properly freed. Fix is to not clear it, so ngx_regex_cleanup() will be able to free it. Reported by ZhenZhong Wu, https://mailman.nginx.org/pipermail/nginx-devel/2023-September/3Z5FIKUDRN2WBSL3JWTZJ7SXDA6YIWPB.html
2023-09-13Modules compatibility: added QUIC to signature (ticket #2539).Roman Arutyunyan1-0/+5
Enabling QUIC changes ngx_connection_t layout, which is why it should be added to the signature.
2023-08-25Version bump.Sergey Kandaurov1-2/+2
2023-08-14QUIC: path MTU discovery.Roman Arutyunyan2-1/+7
MTU selection starts by doubling the initial MTU until the first failure. Then binary search is used to find the path MTU.
2023-07-19Core: fixed environment variables on exit.Maxim Dounin1-2/+51
Similarly to 6822:c045b4926b2c, environment variables introduced with the "env" directive (and "NGINX_BPF_MAPS" added by QUIC) are now allocated via ngx_alloc(), and explicitly freed by a cleanup handler if no longer used. In collaboration with Sergey Kandaurov.
2023-06-20Version bump.Roman Arutyunyan1-2/+2
2023-05-29Version bump.Roman Arutyunyan1-2/+2
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).