You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by sf...@apache.org on 2016/11/21 20:32:40 UTC
svn commit: r1770750 - in /httpd/httpd/trunk: include/mpm_common.h
server/mpm_unix.c
Author: sf
Date: Mon Nov 21 20:32:40 2016
New Revision: 1770750
URL: http://svn.apache.org/viewvc?rev=1770750&view=rev
Log:
ap_reclaim_child_processes(): Implement terminate immediately
The behavior for terminate == 1 was documented but not implemented. Do
that now.
Modified:
httpd/httpd/trunk/include/mpm_common.h
httpd/httpd/trunk/server/mpm_unix.c
Modified: httpd/httpd/trunk/include/mpm_common.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/mpm_common.h?rev=1770750&r1=1770749&r2=1770750&view=diff
==============================================================================
--- httpd/httpd/trunk/include/mpm_common.h (original)
+++ httpd/httpd/trunk/include/mpm_common.h Mon Nov 21 20:32:40 2016
@@ -94,8 +94,7 @@ typedef void ap_reclaim_callback_fn_t(in
* Make sure all child processes that have been spawned by the parent process
* have died. This includes process registered as "other_children".
*
- * @param terminate Not Implemented, value is ignored !!!
- * Either 1 or 0. If 1, send the child processes SIGTERM
+ * @param terminate Either 1 or 0. If 1, send the child processes SIGTERM
* each time through the loop. If 0, give the process time to die
* on its own before signalling it.
* @param mpm_callback Callback invoked for each dead child process
Modified: httpd/httpd/trunk/server/mpm_unix.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm_unix.c?rev=1770750&r1=1770749&r2=1770750&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm_unix.c (original)
+++ httpd/httpd/trunk/server/mpm_unix.c Mon Nov 21 20:32:40 2016
@@ -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, ac
" 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, ac
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_proces
* 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_proces
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 */