summaryrefslogtreecommitdiffhomepage
path: root/src/core (follow)
AgeCommit message (Collapse)AuthorFilesLines
2026-02-11Version bump.Roman Arutyunyan1-2/+2
2026-01-29Output chain: clear the last_buf flag unless inherited.Sergey Kandaurov1-0/+10
For instance, the last_buf flag is used in the http proxy module when creating HTTP/2 requests to indicate the output is closed. The flag is inherited in ngx_output_chain() to a destination buffer when reading the buffered request body. Then it is used in the proxy output filter to mark the last HTTP/2 DATA frame with END_STREAM. The problem happens when reusing the destination buffer, such as to re-read the buffered request body on next upstream, because this buffer may contain a dirty last_buf value, which breaks sending HTTP/2 request body in multiple output filter calls. The flush and last_in_chain flags are cleared for consistency.
2025-12-16Version bump.Aleksei Bavshin1-2/+2
2025-11-06Version bump.Sergey Kandaurov1-2/+2
2025-10-08Version bump.Sergey Kandaurov1-2/+2
2025-09-26Mail: xtext encoding (RFC 3461) in XCLIENT LOGIN.Sergey Kandaurov2-3/+30
The XCLIENT command uses xtext encoding for attribute values, as specified in https://www.postfix.org/XCLIENT_README.html. Reported by Igor Morgenstern of Aisle Research.
2025-08-13Version bump.Sergey Kandaurov1-2/+2
2025-06-25Version bump.Sergey Kandaurov1-2/+2
2025-06-21Use NULL instead of 0 for null pointer constant.Andrew Clayton1-1/+1
There were a few random places where 0 was being used as a null pointer constant. We have a NULL macro for this very purpose, use it. There is also some interest in actually deprecating the use of 0 as a null pointer constant in C. This was found with -Wzero-as-null-pointer-constant which was enabled for C in GCC 15 (not enabled with Wall or Wextra... yet). Link: <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117059>
2025-05-27Core: added support for TCP keepalive parameters on macOS.Sergey Kandaurov1-0/+4
The support first appeared in OS X Mavericks 10.9 and documented since OS X Yosemite 10.10. It has a subtle implementation difference from other operating systems in that the TCP_KEEPALIVE socket option (used in place of TCP_KEEPIDLE) isn't inherited from a listening socket to an accepted socket. An apparent reason for this behaviour is that it might be preserved for the sake of backward compatibility. The TCP_KEEPALIVE socket option is not inherited since appearance in OS X Panther 10.3, which long predates two other TCP_KEEPINTVL and TCP_KEEPCNT socket options. Thanks to Andy Pan for initial work.
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