summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorStefan Fritsch <sf@apache.org>2016-11-21 20:32:40 +0000
committerStefan Fritsch <sf@apache.org>2016-11-21 20:32:40 +0000
commit7d6d92947b104cceaf6f721795c28443691b3093 (patch)
tree68d1e3e6c9c9e68706a5da5f303060185f43ab88 /server
parent11ff28682ff23326c66b470b29b16a3e7cdd1468 (diff)
downloadhttpd-7d6d92947b104cceaf6f721795c28443691b3093.tar.gz
ap_reclaim_child_processes(): Implement terminate immediately
The behavior for terminate == 1 was documented but not implemented. Do that now. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1770750 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'server')
-rw-r--r--server/mpm_unix.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/server/mpm_unix.c b/server/mpm_unix.c
index 140d4e8f68..cd3bc52d51 100644
--- a/server/mpm_unix.c
+++ b/server/mpm_unix.c
@@ -63,7 +63,13 @@
#undef APLOG_MODULE_INDEX
#define APLOG_MODULE_INDEX AP_CORE_MODULE_INDEX
-typedef enum {DO_NOTHING, SEND_SIGTERM, SEND_SIGKILL, GIVEUP} action_t;
+typedef enum {
+ DO_NOTHING,
+ SEND_SIGTERM,
+ SEND_SIGTERM_NOLOG,
+ SEND_SIGKILL,
+ GIVEUP
+} action_t;
typedef struct extra_process_t {
struct extra_process_t *next;
@@ -142,6 +148,8 @@ static int reclaim_one_pid(pid_t pid, action_t action)
" still did not exit, "
"sending a SIGTERM",
pid);
+ /* FALLTHROUGH */
+ case SEND_SIGTERM_NOLOG:
kill(pid, SIGTERM);
break;
@@ -173,7 +181,6 @@ static int reclaim_one_pid(pid_t pid, action_t action)
return 0;
}
-/* XXX The terminate argument is ignored. Implement or remove? */
AP_DECLARE(void) ap_reclaim_child_processes(int terminate,
ap_reclaim_callback_fn_t *mpm_callback)
{
@@ -194,6 +201,7 @@ AP_DECLARE(void) ap_reclaim_child_processes(int terminate,
* children but take no action against
* stragglers
*/
+ {SEND_SIGTERM_NOLOG, 0}, /* skipped if terminate == 0 */
{SEND_SIGTERM, apr_time_from_sec(3)},
{SEND_SIGTERM, apr_time_from_sec(5)},
{SEND_SIGTERM, apr_time_from_sec(7)},
@@ -203,19 +211,21 @@ AP_DECLARE(void) ap_reclaim_child_processes(int terminate,
int cur_action; /* index of action we decided to take this
* iteration
*/
- int next_action = 1; /* index of first real action */
+ int next_action = terminate ? 1 : 2; /* index of first real action */
ap_mpm_query(AP_MPMQ_MAX_DAEMON_USED, &max_daemons);
do {
- apr_sleep(waittime);
- /* don't let waittime get longer than 1 second; otherwise, we don't
- * react quickly to the last child exiting, and taking action can
- * be delayed
- */
- waittime = waittime * 4;
- if (waittime > apr_time_from_sec(1)) {
- waittime = apr_time_from_sec(1);
+ if (action_table[next_action].action_time > 0) {
+ apr_sleep(waittime);
+ /* don't let waittime get longer than 1 second; otherwise, we don't
+ * react quickly to the last child exiting, and taking action can
+ * be delayed
+ */
+ waittime = waittime * 4;
+ if (waittime > apr_time_from_sec(1)) {
+ waittime = apr_time_from_sec(1);
+ }
}
/* see what action to take, if any */