summaryrefslogtreecommitdiffhomepage
path: root/src/core (follow)
AgeCommit message (Collapse)AuthorFilesLines
2017-08-10Style.Maxim Dounin1-2/+2
2017-08-09Style.Sergey Kandaurov1-0/+1
2017-08-09Version bump.Sergey Kandaurov1-2/+2
2017-08-08Slab: fixed initialization on win32.Ruslan Ermilov3-10/+20
On Windows, a worker process does not call ngx_slab_init() from ngx_init_zone_pool(), so ngx_slab_max_size, ngx_slab_exact_size, and ngx_slab_exact_shift were left uninitialized.
2017-07-17Parenthesized ASCII-related calculations.Valentin Bartenev2-12/+12
This also fixes potential undefined behaviour in the range and slice filter modules, caused by local overflows of signed integers in expressions.
2017-07-11Core: fixed error message on setsockopt(SO_REUSEPORT) failure.Maxim Dounin1-1/+1
The error is fatal when configuring a new socket, so the ", ignored" part is not appropriate and was removed.
2017-07-11Core: disabled SO_REUSEPORT when testing config (ticket #1300).Maxim Dounin1-1/+1
When closing a socket with SO_REUSEPORT, Linux drops all connections waiting in this socket's listen queue. Previously, it was believed to only result in connection resets when reconfiguring nginx to use smaller number of worker processes. It also results in connection resets during configuration testing though. Workaround is to avoid using SO_REUSEPORT when testing configuration. It should prevent listening sockets from being created if a conflicting socket already exists, while still preserving detection of other possible errors. It should also cover UDP sockets. The only downside of this approach seems to be that a configuration testing won't be able to properly report the case when nginx was compiled with SO_REUSEPORT, but the kernel is not able to set it. Such errors will be reported on a real start instead.
2017-07-11Version bump.Maxim Dounin1-2/+2
2017-07-04Resolver: cancelable resend timer event.Ruslan Ermilov2-0/+3
It is safe because re-sending still works during graceful shutdown as long as resolving takes place (and resolve tasks set their own timeouts that are not cancelable). Also, the new ctx->cancelable flag can be set to make resolve task's timeout event cancelable.
2017-07-04Resolver: factored out setting a timer for resolver timeout.Sergey Kandaurov1-50/+33
No functional changes.
2017-07-04Slab: fixed small allocations on systems with large pagesize.Ruslan Ermilov1-4/+13
Notably, on ppc64 with 64k pagesize, slab 0 (of size 8) requires 128 64-bit elements for bitmasks. The code bogusly assumed that one uintptr_t is enough for bitmasks plus at least one free slot.
2017-07-04Slab: style.Ruslan Ermilov1-10/+10
2017-07-04Resolver: fixed possible use-after-free while resolving SRV.Roman Arutyunyan1-19/+19
Resolving an SRV record includes resolving its host names in subrequests. Previously, if memory allocation failed while reporting a subrequest result after receiving a response from a DNS server, the SRV resolve handler was called immediately with the NGX_ERROR state. However, if the SRV record included another copy of the resolved name, it was reported once again. This could trigger the use-after-free memory access after SRV resolve handler freed the resolve context by calling ngx_resolve_name_done(). Now the SRV resolve handler is called only when all its subrequests are completed.
2017-07-03Version bump.Maxim Dounin1-2/+2
2017-06-14Resolver: added the "async" flag to resolver context.Roman Arutyunyan2-1/+7
The flag indicates that the resolve handler is called asynchronously after the resolve function ngx_resolve_name()/ngx_resolve_addr() exited.
2017-06-19Resolver: fixed allocation error handling while resolving SRV.Bart Warmerdam1-1/+3
2017-06-16Introduced ngx_rwlock_downgrade().Ruslan Ermilov2-0/+10
2017-06-16Added memory barrier semantics to ngx_rwlock_unlock().Ruslan Ermilov1-1/+1
2017-06-14Removed excessive casts for ngx_file_info().Ruslan Ermilov2-6/+2
2017-05-30Version bump.Valentin Bartenev1-2/+2
2017-05-26Introduced ngx_tcp_nodelay().Ruslan Ermilov2-0/+44
2017-04-27Added missing "fall through" comments (ticket #1259).Maxim Dounin1-0/+2
Found by gcc7 (-Wimplicit-fallthrough).
2017-04-25Version bump.Ruslan Ermilov1-2/+2
2017-04-18Core: removed extra ngx_alloc() and ngx_calloc() prototypes.Sergey Kandaurov1-3/+0
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-12Version bump.Ruslan Ermilov1-2/+2
2017-03-28Use ngx_array_init() to initialize arrays.Ruslan Ermilov1-19/+15
2017-03-28Version bump.Ruslan Ermilov1-2/+2
2017-03-22Version bump.Ruslan Ermilov1-2/+2
2017-03-07Introduced worker_shutdown_timeout.Maxim Dounin3-0/+64
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-07Core: introduced ngx_rbtree_next().Maxim Dounin2-0/+31
2017-03-07Removed casts not needed after 1f513d7f1b45.Ruslan Ermilov1-2/+2
2017-03-02Added missing static specifiers.Eran Kornblau1-4/+4
2017-02-17Fixed ngx_parse_size() / ngx_parse_offset() with 0-length strings.Maxim Dounin1-0/+10
2017-02-16Version bump.Maxim Dounin1-2/+2
2017-01-26Version bump.Vladimir Homutov1-2/+2
2017-01-20Fixed trailer construction with limit on FreeBSD and macOS.Maxim Dounin1-0/+3
The ngx_chain_coalesce_file() function may produce more bytes to send then requested in the limit passed, as it aligns the last file position to send to memory page boundary. As a result, (limit - send) may become negative. This resulted in big positive number when converted to size_t while calling ngx_output_chain_to_iovec(). Another part of the problem is in ngx_chain_coalesce_file(): it changes cl to the next chain link even if the current buffer is only partially sent due to limit. Therefore, if a file buffer was not expected to be fully sent due to limit, and was followed by a memory buffer, nginx called sendfile() with a part of the file buffer, and the memory buffer in trailer. If there were enough room in the socket buffer, this resulted in a part of the file buffer being skipped, and corresponding part of the memory buffer sent instead. The bug was introduced in 8e903522c17a (1.7.8). Configurations affected are ones using limits, that is, limit_rate and/or sendfile_max_chunk, and memory buffers after file ones (may happen when using subrequests or with proxying with disk buffering). Fix is to explicitly check if (send < limit) before constructing trailer with ngx_output_chain_to_iovec(). Additionally, ngx_chain_coalesce_file() was modified to preserve unfinished file buffers in cl.
2017-01-20Improved connection draining with small number of connections.Maxim Dounin2-2/+7
Closing up to 32 connections might be too aggressive if worker_connections is set to a comparable number (and/or there are only a small number of reusable connections). If an occasional connection shorage happens in such a configuration, it leads to closing all reusable connections instead of gradually reducing keepalive timeout to a smaller value. To improve granularity in such configurations we now close no more than 1/8 of all reusable connections at once. Suggested by Joel Cunningham.
2017-01-20Added cycle parameter to ngx_drain_connections().Maxim Dounin1-5/+5
No functional changes, mostly style.
2017-01-10Version bump.Ruslan Ermilov1-2/+2
2016-12-24Win32: support 64-bit compilation with MSVC.Maxim Dounin1-3/+3
There are lots of C4244 warnings (conversion from 'type1' to 'type2', possible loss of data), so they were disabled. The same applies to C4267 warnings (conversion from 'size_t' to 'type', possible loss of data), most notably - conversion from ngx_str_t.len to ngx_variable_value_t.len (which is unsigned:28). Additionally, there is at least one case when it is not possible to fix the warning properly without introducing win32-specific code: recv() on win32 uses "int len", while POSIX defines "size_t len". The ssize_t type now properly defined for 64-bit compilation with MSVC. Caught by warning C4305 (truncation from '__int64' to 'ssize_t'), on "cutoff = NGX_MAX_SIZE_T_VALUE / 10" in ngx_atosz()). Several C4334 warnings (result of 32-bit shift implicitly converted to 64 bits) were fixed by adding explicit conversions. Several C4214 warnings (nonstandard extension used: bit field types other than int) in ngx_http_script.h fixed by changing bit field types from uintptr_t to unsigned.
2016-12-24Win32: fixed some warnings reported by Borland C.Maxim Dounin1-5/+5
Most notably, warning W8012 (comparing signed and unsigned values) reported in multiple places where an unsigned value of small type (e.g., u_short) is promoted to an int and compared to an unsigned value. Warning W8072 (suspicious pointer arithmetic) disabled, it is reported when we increment base pointer in ngx_shm_alloc().
2016-12-16Resolver: fixed handling of partially resolved SRV.Dmitry Volyntsev1-1/+5
The resolver handles SRV requests in two stages. In the first stage it gets all SRV RRs, and in the second stage it resolves the names from SRV RRs into addresses. Previously, if a response to an SRV request was cached, the queries to resolve names were not limited by a timeout. If a response to any of these queries was not received, the SRV request could never complete. If a response to an SRV request was not cached, and some of the queries to resolve names timed out, NGX_RESOLVE_TIMEDOUT was returned instead of successfully resolved addresses. To fix both issues, resolving of names is now always limited by a timeout.
2016-12-16Resolver: fixed a race between parallel name and addr resolves.Dmitry Volyntsev1-2/+2
Previously, ngx_resolve_name() and ngx_resolve_addr() may have rescheduled the resend timer while it was already in progress.
2016-12-16Resolver: fixed possible premature stop of the resend timer.Dmitry Volyntsev1-0/+1
Previously, ngx_resolve_name_done() and ngx_resolve_addr_done() may have stopped the resend timer prematurely while srv_resend_queue was not empty.
2016-12-16Resolver: fixed possible use-after-free in worker on fast shutdown.Ruslan Ermilov1-0/+4
The fix in a3dc657f4e95 was incomplete.
2016-12-15Resolver: fixed possible use-after-free in worker on fast shutdown.Ruslan Ermilov1-0/+4
2016-12-13Version bump.Ruslan Ermilov1-2/+2
2016-12-08Slab: commented bitmap initialization for small allocations.Ruslan Ermilov1-0/+1
2016-12-07Slab: free pages statistics.Ruslan Ermilov2-0/+6