[PATCH] Add configuration option for the timeout for childs handling SIGTERM.
Otto van der Schaaf
oschaaf at we-amp.com
Mon Mar 23 19:39:46 UTC 2015
Hi,
For testing quick termination during high loads, while running with
valgrind, it might be useful to be able to extend the amount of time nginx
allows child processes to wrap up before sending SIGKILL.
For ngx_pagespeed, the current hard-coded default of 1 second seems to be
just short of what we need to be able to reliably test just this scenario,
so I've made a patch so we can run with different values for with and
without valgrind.
Would the following patch be acceptable?
Kind regards,
Otto
# HG changeset patch
# User Otto van der Schaaf <oschaaf at we-amp.com>
# Date 1427138606 -3600
# Mon Mar 23 20:23:26 2015 +0100
# Node ID 92c9d38d7677b5f646112cde94dc40d834d5ef74
# Parent b6eb6ec4fbd9807d75de071fffb000c4f3a5c57d
Add configuration option for the timeout for childs handling SIGTERM.
Adds a configuration option (child_terminate_timeout) to allow tweaking
the amount of time nginx allows child processes before sending SIGKILL.
This is helpful for testing termination with higher loads under valgrind,
as the hard-coded default (1000 ms) might not always be enough.
diff -r b6eb6ec4fbd9 -r 92c9d38d7677 src/core/nginx.c
--- a/src/core/nginx.c Mon Mar 23 21:09:19 2015 +0300
+++ b/src/core/nginx.c Mon Mar 23 20:23:26 2015 +0100
@@ -125,6 +125,13 @@
offsetof(ngx_core_conf_t, rlimit_sigpending),
NULL },
+ { ngx_string("child_terminate_timeout"),
+ NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_msec_slot,
+ 0,
+ offsetof(ngx_core_conf_t, child_terminate_timeout),
+ NULL },
+
{ ngx_string("working_directory"),
NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1,
ngx_conf_set_str_slot,
@@ -955,6 +962,7 @@
ccf->rlimit_nofile = NGX_CONF_UNSET;
ccf->rlimit_core = NGX_CONF_UNSET;
ccf->rlimit_sigpending = NGX_CONF_UNSET;
+ ccf->child_terminate_timeout = NGX_CONF_UNSET_MSEC;
ccf->user = (ngx_uid_t) NGX_CONF_UNSET_UINT;
ccf->group = (ngx_gid_t) NGX_CONF_UNSET_UINT;
@@ -985,6 +993,7 @@
ngx_conf_init_value(ccf->worker_processes, 1);
ngx_conf_init_value(ccf->debug_points, 0);
+ ngx_conf_init_value(ccf->child_terminate_timeout, 1000);
#if (NGX_HAVE_CPU_AFFINITY)
diff -r b6eb6ec4fbd9 -r 92c9d38d7677 src/core/ngx_cycle.h
--- a/src/core/ngx_cycle.h Mon Mar 23 21:09:19 2015 +0300
+++ b/src/core/ngx_cycle.h Mon Mar 23 20:23:26 2015 +0100
@@ -85,6 +85,7 @@
ngx_int_t rlimit_sigpending;
off_t rlimit_core;
+ ngx_msec_t child_terminate_timeout;
int priority;
ngx_uint_t cpu_affinity_n;
diff -r b6eb6ec4fbd9 -r 92c9d38d7677 src/os/unix/ngx_process_cycle.c
--- a/src/os/unix/ngx_process_cycle.c Mon Mar 23 21:09:19 2015 +0300
+++ b/src/os/unix/ngx_process_cycle.c Mon Mar 23 20:23:26 2015 +0100
@@ -189,7 +189,7 @@
sigio = ccf->worker_processes + 2 /* cache processes */;
- if (delay > 1000) {
+ if (delay > ccf->child_terminate_timeout) {
ngx_signal_worker_processes(cycle, SIGKILL);
} else {
ngx_signal_worker_processes(cycle,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20150323/b233e7ed/attachment.html>
More information about the nginx-devel
mailing list