summaryrefslogtreecommitdiffhomepage
path: root/src/os/unix/ngx_process_cycle.c (unfollow)
AgeCommit message (Collapse)AuthorFilesLines
2024-01-29Silenced complaints about socket leaks on forced termination.Maxim Dounin1-5/+5
When graceful shutdown was requested, and then nginx was forced to do fast shutdown, it used to (incorrectly) complain about open sockets left in connections which weren't yet closed when fast shutdown was requested. Fix is to avoid complaining about open sockets when fast shutdown was requested after graceful one. Abnormal termination, if requested with the WINCH signal, can still happen though.
2022-11-23Fixed segfault when switching off master process during upgrade.Maxim Dounin1-10/+0
Binary upgrades are not supported without master process, but it is, however, possible, that nginx running with master process is asked to upgrade binary, and the configuration file as available on disk at this time includes "master_process off;". If this happens, listening sockets inherited from the previous binary will have ls[i].previous set. But the old cycle on initial process startup, including startup after binary upgrade, is destroyed by ngx_init_cycle() once configuration parsing is complete. As a result, an attempt to dereference ls[i].previous in ngx_event_process_init() accesses already freed memory. Fix is to avoid looking into ls[i].previous if the old cycle is already freed. With this change it is also no longer needed to clear ls[i].previous in worker processes, so the relevant code was removed.
2022-11-18Process events posted by ngx_close_idle_connections() immediately.Roman Arutyunyan1-0/+1
Previously, if an event was posted by a read event handler, called by ngx_close_idle_connections(), that event was not processed until the next event loop iteration, which could happen after a timeout.
2021-04-22Restored zeroing of ngx_channel_t in ngx_pass_open_channel().Ruslan Ermilov1-0/+2
Due to structure's alignment, some uninitialized memory contents may have been passed between processes. Zeroing was removed in 0215ec9aaa8a. Reported by Johnny Wang.
2021-03-11Removed "ch" argument from ngx_pass_open_channel().Ruslan Ermilov1-39/+18
2020-06-01Fixed SIGQUIT not removing listening UNIX sockets (closes #753).Ruslan Ermilov1-12/+2
Listening UNIX sockets were not removed on graceful shutdown, preventing the next runs. The fix is to replace the custom socket closing code in ngx_master_process_cycle() by the ngx_close_listening_sockets() call.
2017-12-19Fixed capabilities version.Roman Arutyunyan1-1/+1
Previously, capset(2) was called with the 64-bit capabilities version _LINUX_CAPABILITY_VERSION_3. With this version Linux kernel expected two copies of struct __user_cap_data_struct, while only one was submitted. As a result, random stack memory was accessed and random capabilities were requested by the worker. This sometimes caused capset() errors. Now the 32-bit version _LINUX_CAPABILITY_VERSION_1 is used instead. This is OK since CAP_NET_RAW is a 32-bit capability (CAP_NET_RAW = 13).
2017-12-18Improved the capabilities feature detection.Roman Arutyunyan1-1/+1
Previously included file sys/capability.h mentioned in capset(2) man page, belongs to the libcap-dev package, which may not be installed on some Linux systems when compiling nginx. This prevented the capabilities feature from being detected and compiled on that systems. Now linux/capability.h system header is included instead. Since capset() declaration is located in sys/capability.h, now capset() syscall is defined explicitly in code using the SYS_capset constant, similarly to other Linux-specific features in nginx.
2017-12-13Retain CAP_NET_RAW capability for transparent proxying.Roman Arutyunyan1-0/+32
The capability is retained automatically in unprivileged worker processes after changing UID if transparent proxying is enabled at least once in nginx configuration. The feature is only available in Linux.
2017-11-28Fixed "changing binary" when reaper is not init.Ruslan Ermilov1-0/+1
On some systems, it's possible that reaper of orphaned processes is set to something other than "init" process. On such systems, the changing binary procedure did not work. The fix is to check if PPID has changed, instead of assuming it's always 1 for orphaned processes.
2017-03-07Style.Maxim Dounin1-2/+0
2017-03-07Introduced worker_shutdown_timeout.Maxim Dounin1-0/+1
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-07Cancelable timers are now preserved if there are other timers.Maxim Dounin1-4/+1
There is no need to cancel timers early if there are other timers blocking shutdown anyway. Preserving such timers allows nginx to continue some periodic work till the shutdown is actually possible. With the new approach, timers with ev->cancelable are simply ignored when checking if there are any timers left during shutdown.
2016-10-05Cache: cache manager limits.Dmitry Volyntsev1-3/+3
The new parameters "manager_files", "manager_sleep" and "manager_threshold" were added to proxy_cache_path and friends. Note that ngx_path_manager_pt was changed to return ngx_msec_t instead of time_t (API change).
2016-08-04Always seed PRNG with PID, seconds, and milliseconds.Ruslan Ermilov1-1/+3
2016-08-04Fixed undefined behavior when left shifting signed integer.Ruslan Ermilov1-1/+1
2016-03-31Fixed logging.Sergey Kandaurov1-5/+5
2016-02-18Core: added support for more than 64 CPUs in worker_cpu_affinity.Vladimir Homutov1-1/+1
2016-02-04Dynamic modules: changed ngx_modules to cycle->modules.Maxim Dounin1-15/+15
2015-08-11Core: idle connections now closed only once on exiting.Valentin Bartenev1-17/+2
Iterating through all connections takes a lot of CPU time, especially with large number of worker connections configured. As a result nginx processes used to consume CPU time during graceful shutdown. To mitigate this we now only do a full scan for idle connections when shutdown signal is received. Transitions of connections to idle ones are now expected to be avoided if the ngx_exiting flag is set. The upstream keepalive module was modified to follow this.
2015-05-20Introduced worker number, ngx_worker.Maxim Dounin1-0/+2
2015-04-23Removed the "worker_rlimit_sigpending" directive.Ruslan Ermilov1-13/+0
It was only needed by the just removed rtsig module.
2015-03-20Removed unix ngx_threaded and related ngx_process_changes.Ruslan Ermilov1-1/+0
2015-03-20Removed old pthread implementation.Ruslan Ermilov1-188/+0
2015-03-04Renamed NGX_THREADS to NGX_OLD_THREADS because of deprecation.Ruslan Ermilov1-5/+5
It's mostly dead code and the original idea of worker threads has been rejected.
2014-08-13Events: introduced cancelable timers.Valentin Bartenev1-0/+2
2014-08-25Events: removed broken thread support from event timers.Valentin Bartenev1-1/+0
It's mostly dead code. And the idea of thread support for this task has been deprecated.
2014-09-01Events: removed broken thread support from posted events.Valentin Bartenev1-5/+4
It's mostly dead code. And the idea of thread support for this task has been deprecated.
2014-08-01Core: exit on ngx_pnalloc() failure.Piotr Sikora1-0/+4
Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-05-12Added syslog support for error_log and access_log directives.Vladimir Homutov1-4/+7
2014-03-06Added connection serial number in logging of left open sockets.Sergey Kandaurov1-2/+2
2014-01-04Added per-process random seeding (ticket #456).Maxim Dounin1-0/+2
2013-07-11Style.Maxim Dounin1-1/+1
2013-06-20Core: support several "error_log" directives.Vladimir Homutov1-0/+2
When several "error_log" directives are specified in the same configuration block, logs are written to all files with a matching log level. All logs are stored in the singly-linked list that is sorted by log level in the descending order. Specific debug levels (NGX_LOG_DEBUG_HTTP,EVENT, etc.) are not supported if several "error_log" directives are specified. In this case all logs will use debug level that has largest absolute value.
2013-06-05Valgrind: supressed complaints about uninitialized bytes.Maxim Dounin1-0/+8
Valgrind complains if we pass uninitialized memory to a syscall: ==36492== Syscall param sendmsg(msg.msg_iov[0]) points to uninitialised byte(s) ==36492== at 0x6B5E6A: sendmsg (in /usr/lib/system/libsystem_kernel.dylib) ==36492== by 0x10004288E: ngx_signal_worker_processes (ngx_process_cycle.c:527) ==36492== by 0x1000417A7: ngx_master_process_cycle (ngx_process_cycle.c:203) ==36492== by 0x100001F10: main (nginx.c:410) ==36492== Address 0x7fff5fbff71c is on thread 1's stack Even initialization of all members of the structure passed isn't enough, as there is padding which still remains uninitialized and results in Valgrind complaint. Note there is no real problem here as data from uninitialized memory isn't used.
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-11-20Fixed failure to start cache manager and cache loader processesIgor Sysoev1-4/+9
if there were more than 512 listening sockets in configuration.
2012-11-16Fixed setting of CPU affinity on respawn of dead worker processes.Ruslan Ermilov1-14/+16
Worker processes are now made aware of their sequential number needed to select CPU affinity mask. This replaces a workaround from r4865.
2012-09-28Correct plural form for "path" in the whole source base.Andrey Belov1-6/+6
2012-09-26Added clearing of cpu_affinity after process spawn.Maxim Dounin1-0/+2
This fixes unwanted/incorrect cpu_affinity use on dead worker processes respawn. While this is not ideal, it's expected to be better when previous situation where multiple processes were spawn with identical CPU affinity set. Reported by Charles Chen.
2012-06-18Fixed segfault with poll and resolver used.Maxim Dounin1-0/+4
Poll event method needs ngx_cycle->files to work, and use of ngx_exit_cycle without files set caused null pointer dereference in resolver's cleanup on udp socket close.
2012-03-21worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.Ruslan Ermilov1-15/+2
2012-02-28Added msleep() on reload to allow new processes to start.Maxim Dounin1-0/+4
This is expected to ensure smoother operation on reload (and with less chance of listen queue overflows). Prodded by Igor Sysoev.
2012-01-18Copyright updated.Maxim Konovalov1-0/+1
2012-01-16Fixed sched_setaffinity(2) to correctly pass size.Maxim Dounin1-1/+4
Second argument (cpusetsize) is size in bytes, not in bits. Previously used constant 32 resulted in reading of uninitialized memory and caused EINVAL to be returned on some Linux kernels.
2011-09-19Replaced "can not" with "cannot" and "could not" in a bunch of places.Ruslan Ermilov1-1/+2
Fixed nearby grammar errors.
2010-12-13allow "env" to work in the single process modeIgor Sysoev1-0/+5
2010-09-15worker_rlimit_core should be off_tIgor Sysoev1-2/+2
2010-03-25*) introduce ngx_time_sigsafe_update() to update the error log time onlyIgor Sysoev1-3/+3
*) change ngx_time_update() interface
2010-03-13*) use previously cached GMT offset value to update time from a signal handlerIgor Sysoev1-3/+3
*) change ngx_time_update() interface since there are no notification methods those return time