summaryrefslogtreecommitdiffhomepage
path: root/src/core/ngx_cycle.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
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.
2020-11-19Core: "-e" command line option.Igor Ippolitov1-0/+9
When installing or running from a non-root user it is sometimes required to override default, compiled in error log path. There was no way to do this without rebuilding the binary (ticket #147). This patch introduced "-e" command line option which allows one to override compiled in error log path.
2020-07-21Core: close PID file when writing fails.Ruslan Ermilov1-2/+5
Reported by Jinhua Tan.
2020-06-01Fixed removing of listening UNIX sockets when "changing binary".Ruslan Ermilov1-0/+1
When changing binary, sending a SIGTERM to the new binary's master process should not remove inherited UNIX sockets unless the old binary's master process has exited.
2018-11-15Core: free shared memory on cycle initialization failure.Ruslan Ermilov1-0/+64
2018-10-02Fixed off-by-one error in shared zone initialization.Ruslan Ermilov1-1/+2
On systems without atomic ops, not enough space was allocated for mutex's file name during shared zone initialization.
2017-10-17Core: free shared memory zones only after reconfiguration.Maxim Dounin1-7/+17
This is what usually happens for zones no longer used in the new configuration, but zones where size or tag were changed were freed when creating new memory zones. If reconfiguration failed (for example, due to a conflicting listening socket), this resulted in a segmentation fault in the master process. Reported by Zhihua Cao, http://mailman.nginx.org/pipermail/nginx-devel/2017-October/010536.html.
2017-06-14Removed excessive casts for ngx_file_info().Ruslan Ermilov1-3/+1
2017-03-28Use ngx_array_init() to initialize arrays.Ruslan Ermilov1-19/+15
2017-03-07Introduced worker_shutdown_timeout.Maxim Dounin1-0/+53
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.
2016-12-07Perl: removed special environment handling for the perl module.Maxim Dounin1-12/+1
In Perl 5.8.6 the default was switched to use putenv() when used as embedded library unless "PL_use_safe_putenv = 0" is explicitly used in the code. Therefore, for modern versions of Perl it is no longer necessary to restore previous environment when calling perl_destruct().
2016-10-18Core: show file contents only once while dumping configuration.Vladimir Homutov1-0/+3
Files are considered the same if the path used by nginx during parsing matches.
2016-03-31Fixed ngx_os_signal_process() prototype.Ruslan Ermilov1-2/+2
2016-03-31Fixed logging.Sergey Kandaurov1-3/+3
2016-03-25Fixed socket inheritance on reload and binary upgrade.Roman Arutyunyan1-0/+4
On nginx reload or binary upgrade, an attempt is made to inherit listen sockets from the previous configuration. Previously, no check for socket type was made and the inherited socket could have the wrong type. On binary upgrade, socket type was not detected at all. Wrong socket type could lead to errors on that socket due to different logic and unsupported syscalls. For example, a UDP socket, inherited as TCP, lead to the following error after arrival of a datagram: "accept() failed (102: Operation not supported on socket)".
2016-02-04Dynamic modules.Maxim Dounin1-1/+4
The auto/module script is extended to understand ngx_module_link=DYNAMIC. When set, it links the module as a shared object rather than statically into nginx binary. The module can later be loaded using the "load_module" directive. New auto/module parameter ngx_module_order allows to define module loading order in complex cases. By default the order is set based on ngx_module_type. 3rd party modules can be compiled dynamically using the --add-dynamic-module configure option, which will preset ngx_module_link to "DYNAMIC" before calling the module config script. Win32 support is rudimentary, and only works when using MinGW gcc (which is able to handle exports/imports automatically). In collaboration with Ruslan Ermilov.
2016-02-04Dynamic modules: changed ngx_modules to cycle->modules.Maxim Dounin1-8/+12
2016-02-04Dynamic modules: moved module-related stuff to separate files.Maxim Dounin1-7/+3
2015-05-14Core: store and dump processed configuration.Vladimir Homutov1-0/+8
If the -T option is passed, additionally to configuration test, configuration files are output to stdout. In the debug mode, configuration files are kept in memory and can be accessed using a debugger.
2015-05-20The "reuseport" option of the "listen" directive.Maxim Dounin1-0/+11
When configured, an individual listen socket on a given address is created for each worker process. This allows to reduce in-kernel lock contention on configurations with high accept rates, resulting in better performance. As of now it works on Linux and DragonFly BSD. Note that on Linux incoming connection requests are currently tied up to a specific listen socket, and if some sockets are closed, connection requests will be reset, see https://lwn.net/Articles/542629/. With nginx, this may happen if the number of worker processes is reduced. There is no such problem on DragonFly BSD. Based on previous work by Sepherosa Ziehau and Yingqi Lu.
2015-04-27Win32: shared memory base addresses and remapping.Maxim Dounin1-0/+16
Two mechanisms are implemented to make it possible to store pointers in shared memory on Windows, in particular on Windows Vista and later versions with ASLR: - The ngx_shm_remap() function added to allow remapping of a shared memory zone to the address originally used for it in the master process. While important, it doesn't solve the problem by itself as in many cases it's not possible to use the address because of conflicts with other allocations. - We now create mappings at the same address in all processes by starting mappings at predefined addresses normally unused by newborn processes. These two mechanisms combined allow to use shared memory on Windows almost without problems, including reloads. Based on the patch by Sergey Brester: http://mailman.nginx.org/pipermail/nginx-devel/2015-April/006836.html
2015-04-27Win32: fixed shm.handle loss on reload.Maxim Dounin1-0/+3
2015-04-20Core: allow shared memory size to be declared after a reference.Sergey Kandaurov1-0/+4
For example, this fixes the case when "proxy_cache_path" is specified after "proxy_cache" that references it.
2015-03-26Removed unused thread-local-storage code.Ruslan Ermilov1-4/+0
2015-04-14Upstream: the "zone" directive.Ruslan Ermilov1-1/+3
Upstreams with the "zone" directive are kept in shared memory, with a consistent view of all worker processes.
2015-03-04Renamed NGX_THREADS to NGX_OLD_THREADS because of deprecation.Ruslan Ermilov1-1/+1
It's mostly dead code and the original idea of worker threads has been rejected.
2014-04-30Core: fixed error handling in ngx_reopen_files().Maxim Dounin1-0/+6
Found by Coverity (CID 1087509).
2014-03-07Core: fixed wrong indices in listening sockets compare loops.Maxim Dounin1-3/+3
Proper use is "ls[i]" and "nls[n]". Previous code used it wrong in several places, likely due to cut-n-paste errors.
2013-12-06Core: externalized ngx_cmp_sockaddr().Ruslan Ermilov1-70/+3
It's also extended with the "cmp_port" argument to indicate whether ports should be compared as well, or only addresses.
2013-10-24Core: apply missed options to sockets added during binary upgrade.Piotr Sikora1-0/+10
The accept_filter and deferred options were not applied to sockets that were added to configuration during binary upgrade cycle. Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2013-09-04Win32: MinGW GCC compatibility.Maxim Dounin1-3/+3
Several warnings silenced, notably (ngx_socket_t) -1 is now checked on socket operations instead of -1, as ngx_socket_t is unsigned on win32 and gcc complains on comparison. With this patch, it's now possible to compile nginx using mingw gcc, with options we normally compile on win32.
2013-06-28Core: consolidated log-related code.Vladimir Homutov1-23/+5
The stderr redirection code is moved to ngx_log_redirect_stderr(). The opening of the default log code is moved to ngx_log_open_default().
2013-06-13Core: moved initialization of log level.Vladimir Homutov1-1/+2
The cycle->new_log->log_level should only be initialized by ngx_init_cycle() if no error logs were found in the configuration. This move allows to get rid of extra initialization in ngx_error_log().
2013-06-04Core: fixed handling of "stderr" in error_log.Vladimir Homutov1-3/+4
If "stderr" was specified in one of the "error_log" directives, stderr is not redirected to the first error_log on startup, configuration reload, and reopening log files.
2013-06-03Core: fixed stderr redirection on win32 in ngx_reopen_files().Vladimir Homutov1-7/+4
On win32 stderr was not redirected into a file specified by "error_log" while reopening files. Fix is to use platform-independent functions to work with stderr, as already used by ngx_init_cycle() and main() since rev. d8316f307b6a.
2013-03-25Use NGX_FILE_ERROR for handling file operations errors.Valentin Bartenev1-1/+1
On Win32 platforms 0 is used to indicate errors in file operations, so comparing against -1 is not portable. This was not much of an issue in patched code, since only ngx_fd_info() test is actually reachable on Win32 and in worst case it might result in bogus error log entry. Patch by Piotr Sikora.
2012-12-23Reopening log files code moved to a separate function.Valentin Bartenev1-19/+2
The code refactored in a way to call custom handler that can do appropriate cleanup work (if any), like flushing buffers, finishing compress streams, finalizing connections to log daemon, etc..
2012-12-14Fixed handling of ngx_write_fd() and ngx_read_fd() errors.Valentin Bartenev1-1/+1
The ngx_write_fd() and ngx_read_fd() functions return -1 in case of error, so the incorrect comparison with NGX_FILE_ERROR (which is 0 on windows platforms) might result in inaccurate error message in the error log. Also the ngx_errno global variable is being set only if the returned value is -1.
2012-11-23Core: don't reuse shared memory zone that changed ownership (ticket #210).Ruslan Ermilov1-1/+3
nginx doesn't allow the same shared memory zone to be used for different purposes, but failed to check this on reconfiguration. If a shared memory zone was used for another purpose in the new configuration, nginx attempted to reuse it and crashed.
2012-09-28Correct plural form for "path" in the whole source base.Andrey Belov1-8/+8
2012-09-28Made sure to initialize the entire ngx_file_t structure.Andrey Belov1-0/+2
Found by Coverity.
2012-08-01Reorder checks in ngx_shared_memory_add() for more consistent error messages.Andrey Belov1-8/+8
2012-01-18Copyright updated.Maxim Konovalov1-0/+1
2011-11-23Added shmtx interface to forcibly unlock mutexes.Maxim Dounin1-1/+1
It is currently used from master process on abnormal worker termination to unlock accept mutex (unlocking of accept mutex was broken in 1.0.2). It is expected to be used in the future to unlock other mutexes as well. Shared mutex code was rewritten to make this possible in a safe way, i.e. with a check if lock was actually held by the exited process. We again use pid to lock mutex, and use separate atomic variable for a count of processes waiting in sem_wait().
2011-09-19Replaced "can not" with "cannot" and "could not" in a bunch of places.Ruslan Ermilov1-1/+1
Fixed nearby grammar errors.
2011-08-04A new fix for the case when ssl_session_cache defined, but ssl is notIgor Sysoev1-5/+0
enabled in any server. The previous r1033 does not help when unused zone becomes used after reconfiguration, so it is backed out. The initial thought was to make SSL modules independed from SSL implementation and to keep OpenSSL code dependance as much as in separate files.
2011-04-04reuse keepalive connections if there are no free worker connectionsIgor Sysoev1-0/+3
patch by Maxim Dounin
2010-09-02the -q switchIgor Sysoev1-1/+2
2010-06-30fix IPv6 listen socket handling while reconfiguringIgor Sysoev1-1/+1
2010-06-04*) delete no longer used unix domain socketsIgor Sysoev1-0/+36
*) fix unix domain socket comparison