Changes with Apache 2.4.7
+ *) mpm_unix: Add ap_mpm_podx_* implementation to avoid code duplication
+ and align w/ trunk. [Jim Jagielski]
+
*) Fix potential rejection of valid MaxMemFree and ThreadStackSize
directives. [Mike Rumph <mike.rumph oracle.com>]
PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
[ start all new proposals below, under PATCHES PROPOSED. ]
- * mpm_unix: Add ap_mpm_podx_* implementation to avoid code duplication
- and align w/ trunk.
- trunk patch: http://svn.apache.org/viewvc?view=revision&revision=1409214
- http://svn.apache.org/viewvc?view=revision&revision=1410004
- 2.4.x patch: http://people.apache.org/~jim/patches/httpd-2.4-podx-v2.patch
- +1: jim, rjung, minfrin
PATCHES PROPOSED TO BACKPORT FROM TRUNK:
* 20120211.24 (2.4.7-dev) add open_htaccess hook.
* 20120211.25 (2.4.7-dev) Add conn_sense_e
* 20120211.26 (2.4.7-dev) Add util_fcgi.h, FastCGI protocol support
+ * 20120211.27 (2.4.7-dev) Add ap_podx_restart_t and ap_mpm_podx_*
*/
#define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
#ifndef MODULE_MAGIC_NUMBER_MAJOR
#define MODULE_MAGIC_NUMBER_MAJOR 20120211
#endif
-#define MODULE_MAGIC_NUMBER_MINOR 26 /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 27 /* 0...n */
/**
* Determine if the server's current MODULE_MAGIC_NUMBER is at least a
*/
AP_DECLARE(void) ap_mpm_pod_killpg(ap_pod_t *pod, int num);
+#define AP_MPM_PODX_RESTART_CHAR '$'
+#define AP_MPM_PODX_GRACEFUL_CHAR '!'
+
+typedef enum { AP_MPM_PODX_NORESTART, AP_MPM_PODX_RESTART, AP_MPM_PODX_GRACEFUL } ap_podx_restart_t;
+
+/**
+ * Open the extended pipe-of-death.
+ * @param p The pool to use for allocating the pipe
+ * @param pod The pipe-of-death that is created.
+ */
+AP_DECLARE(apr_status_t) ap_mpm_podx_open(apr_pool_t *p, ap_pod_t **pod);
+
+/**
+ * Check the extended pipe to determine if the process has been signalled to die.
+ */
+AP_DECLARE(int) ap_mpm_podx_check(ap_pod_t *pod);
+
+/**
+ * Close the pipe-of-death
+ *
+ * @param pod The pipe-of-death to close.
+ */
+AP_DECLARE(apr_status_t) ap_mpm_podx_close(ap_pod_t *pod);
+
+/**
+ * Write data to the extended pipe-of-death, signalling that one child process
+ * should die.
+ * @param pod the pipe-of-death to write to.
+ * @param graceful restart-type
+ */
+AP_DECLARE(apr_status_t) ap_mpm_podx_signal(ap_pod_t *pod,
+ ap_podx_restart_t graceful);
+
+/**
+ * Write data to the extended pipe-of-death, signalling that all child process
+ * should die.
+ * @param pod The pipe-of-death to write to.
+ * @param num The number of child processes to kill
+ * @param graceful restart-type
+ */
+AP_DECLARE(void) ap_mpm_podx_killpg(ap_pod_t *pod, int num,
+ ap_podx_restart_t graceful);
+
+
#endif /* !WIN32 || DOXYGEN */
/**
APACHE_SUBST(MOD_MPM_EVENT_LDADD)
-APACHE_MPM_MODULE(event, $enable_mpm_event, event.lo fdqueue.lo pod.lo,[
+APACHE_MPM_MODULE(event, $enable_mpm_event, event.lo fdqueue.lo,[
AC_CHECK_FUNCS(pthread_kill)
], , [\$(MOD_MPM_EVENT_LDADD)])
#include "http_core.h" /* for get_remote_host */
#include "http_connection.h"
#include "ap_mpm.h"
-#include "pod.h"
#include "mpm_common.h"
#include "ap_listen.h"
#include "scoreboard.h"
#define ID_FROM_CHILD_THREAD(c, t) ((c * thread_limit) + t)
-static ap_event_pod_t *pod;
+static ap_pod_t *pod;
/* The event MPM respects a couple of runtime flags that can aid
* in debugging. Setting the -DNO_DETACH flag will prevent the root process
apr_signal(SIGTERM, dummy_signal_handler);
/* Watch for any messages from the parent over the POD */
while (1) {
- rv = ap_event_pod_check(pod);
- if (rv == AP_NORESTART) {
+ rv = ap_mpm_podx_check(pod);
+ if (rv == AP_MPM_PODX_NORESTART) {
/* see if termination was triggered while we slept */
switch (terminate_mode) {
case ST_GRACEFUL:
- rv = AP_GRACEFUL;
+ rv = AP_MPM_PODX_GRACEFUL;
break;
case ST_UNGRACEFUL:
- rv = AP_RESTART;
+ rv = AP_MPM_PODX_RESTART;
break;
}
}
- if (rv == AP_GRACEFUL || rv == AP_RESTART) {
+ if (rv == AP_MPM_PODX_GRACEFUL || rv == AP_MPM_PODX_RESTART) {
/* make sure the start thread has finished;
* signal_threads() and join_workers depend on that
*/
join_start_thread(start_thread_id);
signal_threads(rv ==
- AP_GRACEFUL ? ST_GRACEFUL : ST_UNGRACEFUL);
+ AP_MPM_PODX_GRACEFUL ? ST_GRACEFUL : ST_UNGRACEFUL);
break;
}
}
if (idle_thread_count > max_spare_threads) {
/* Kill off one child */
- ap_event_pod_signal(pod, TRUE);
+ ap_mpm_podx_signal(pod, AP_MPM_PODX_GRACEFUL);
retained->idle_spawn_rate = 1;
}
else if (idle_thread_count < min_spare_threads) {
/* Time to shut down:
* Kill child processes, tell them to call child_exit, etc...
*/
- ap_event_pod_killpg(pod, ap_daemons_limit, FALSE);
+ ap_mpm_podx_killpg(pod, ap_daemons_limit, AP_MPM_PODX_RESTART);
ap_reclaim_child_processes(1, /* Start with SIGTERM */
event_note_child_killed);
/* Close our listeners, and then ask our children to do same */
ap_close_listeners();
- ap_event_pod_killpg(pod, ap_daemons_limit, TRUE);
+ ap_mpm_podx_killpg(pod, ap_daemons_limit, AP_MPM_PODX_GRACEFUL);
ap_relieve_child_processes(event_note_child_killed);
if (!child_fatal) {
* way, try and make sure that all of our processes are
* really dead.
*/
- ap_event_pod_killpg(pod, ap_daemons_limit, FALSE);
+ ap_mpm_podx_killpg(pod, ap_daemons_limit, AP_MPM_PODX_RESTART);
ap_reclaim_child_processes(1, event_note_child_killed);
return DONE;
AP_SIG_GRACEFUL_STRING
" received. Doing graceful restart");
/* wake up the children...time to die. But we'll have more soon */
- ap_event_pod_killpg(pod, ap_daemons_limit, TRUE);
+ ap_mpm_podx_killpg(pod, ap_daemons_limit, AP_MPM_PODX_GRACEFUL);
/* This is mostly for debugging... so that we know what is still
* and a SIGHUP, we may as well use the same signal, because some user
* pthreads are stealing signals from us left and right.
*/
- ap_event_pod_killpg(pod, ap_daemons_limit, FALSE);
+ ap_mpm_podx_killpg(pod, ap_daemons_limit, AP_MPM_PODX_RESTART);
ap_reclaim_child_processes(1, /* Start with SIGTERM */
event_note_child_killed);
}
if (!one_process) {
- if ((rv = ap_event_pod_open(pconf, &pod))) {
+ if ((rv = ap_mpm_podx_open(pconf, &pod))) {
ap_log_error(APLOG_MARK, APLOG_CRIT | level_flags, rv,
(startup ? NULL : s),
"could not open pipe-of-death");
+++ /dev/null
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "pod.h"
-
-#include "apr_portable.h"
-
-#if APR_HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-APLOG_USE_MODULE(mpm_event);
-
-AP_DECLARE(apr_status_t) ap_event_pod_open(apr_pool_t * p, ap_event_pod_t ** pod)
-{
- apr_status_t rv;
-
- *pod = apr_palloc(p, sizeof(**pod));
- rv = apr_file_pipe_create(&((*pod)->pod_in), &((*pod)->pod_out), p);
- if (rv != APR_SUCCESS) {
- return rv;
- }
-/*
- apr_file_pipe_timeout_set((*pod)->pod_in, 0);
-*/
- (*pod)->p = p;
-
- /* close these before exec. */
- apr_file_inherit_unset((*pod)->pod_in);
- apr_file_inherit_unset((*pod)->pod_out);
-
- return APR_SUCCESS;
-}
-
-AP_DECLARE(int) ap_event_pod_check(ap_event_pod_t * pod)
-{
- char c;
- apr_os_file_t fd;
- int rc;
-
- /* we need to surface EINTR so we'll have to grab the
- * native file descriptor and do the OS read() ourselves
- */
- apr_os_file_get(&fd, pod->pod_in);
- rc = read(fd, &c, 1);
- if (rc == 1) {
- switch (c) {
- case RESTART_CHAR:
- return AP_RESTART;
- case GRACEFUL_CHAR:
- return AP_GRACEFUL;
- }
- }
- return AP_NORESTART;
-}
-
-AP_DECLARE(apr_status_t) ap_event_pod_close(ap_event_pod_t * pod)
-{
- apr_status_t rv;
-
- rv = apr_file_close(pod->pod_out);
- if (rv != APR_SUCCESS) {
- return rv;
- }
-
- rv = apr_file_close(pod->pod_in);
- if (rv != APR_SUCCESS) {
- return rv;
- }
- return rv;
-}
-
-static apr_status_t pod_signal_internal(ap_event_pod_t * pod, int graceful)
-{
- apr_status_t rv;
- char char_of_death = graceful ? GRACEFUL_CHAR : RESTART_CHAR;
- apr_size_t one = 1;
-
- rv = apr_file_write(pod->pod_out, &char_of_death, &one);
- if (rv != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_WARNING, rv, ap_server_conf, APLOGNO(00522)
- "write pipe_of_death");
- }
- return rv;
-}
-
-AP_DECLARE(apr_status_t) ap_event_pod_signal(ap_event_pod_t * pod, int graceful)
-{
- return pod_signal_internal(pod, graceful);
-}
-
-AP_DECLARE(void) ap_event_pod_killpg(ap_event_pod_t * pod, int num, int graceful)
-{
- int i;
- apr_status_t rv = APR_SUCCESS;
-
- for (i = 0; i < num && rv == APR_SUCCESS; i++) {
- rv = pod_signal_internal(pod, graceful);
- }
-}
+++ /dev/null
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @file event/pod.h
- * @brief pod definitions
- *
- * @addtogroup APACHE_MPM_EVENT
- * @{
- */
-
-#include "apr.h"
-#include "apr_strings.h"
-#define APR_WANT_STRFUNC
-#include "apr_want.h"
-
-#include "httpd.h"
-#include "http_config.h"
-#include "http_log.h"
-#include "http_main.h"
-#include "mpm_common.h"
-#include "ap_mpm.h"
-#include "ap_listen.h"
-#include "mpm_default.h"
-
-#define RESTART_CHAR '$'
-#define GRACEFUL_CHAR '!'
-
-#define AP_RESTART 0
-#define AP_GRACEFUL 1
-
-typedef struct ap_event_pod_t ap_event_pod_t;
-
-struct ap_event_pod_t
-{
- apr_file_t *pod_in;
- apr_file_t *pod_out;
- apr_pool_t *p;
-};
-
-AP_DECLARE(apr_status_t) ap_event_pod_open(apr_pool_t * p, ap_event_pod_t ** pod);
-AP_DECLARE(int) ap_event_pod_check(ap_event_pod_t * pod);
-AP_DECLARE(apr_status_t) ap_event_pod_close(ap_event_pod_t * pod);
-AP_DECLARE(apr_status_t) ap_event_pod_signal(ap_event_pod_t * pod, int graceful);
-AP_DECLARE(void) ap_event_pod_killpg(ap_event_pod_t * pod, int num, int graceful);
-/** @} */
dnl ## XXX - Need a more thorough check of the proper flags to use
-APACHE_MPM_MODULE(worker, $enable_mpm_worker, worker.lo fdqueue.lo pod.lo,[
+APACHE_MPM_MODULE(worker, $enable_mpm_worker, worker.lo fdqueue.lo,[
AC_CHECK_FUNCS(pthread_kill)
])
+++ /dev/null
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "apr_portable.h"
-#include "pod.h"
-
-#if APR_HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-APLOG_USE_MODULE(mpm_worker);
-
-AP_DECLARE(apr_status_t) ap_worker_pod_open(apr_pool_t *p, ap_worker_pod_t **pod)
-{
- apr_status_t rv;
-
- *pod = apr_palloc(p, sizeof(**pod));
- rv = apr_file_pipe_create(&((*pod)->pod_in), &((*pod)->pod_out), p);
- if (rv != APR_SUCCESS) {
- return rv;
- }
-/*
- apr_file_pipe_timeout_set((*pod)->pod_in, 0);
-*/
- (*pod)->p = p;
-
- /* close these before exec. */
- apr_file_inherit_unset((*pod)->pod_in);
- apr_file_inherit_unset((*pod)->pod_out);
-
- return APR_SUCCESS;
-}
-
-AP_DECLARE(int) ap_worker_pod_check(ap_worker_pod_t *pod)
-{
- char c;
- apr_os_file_t fd;
- int rc;
-
- /* we need to surface EINTR so we'll have to grab the
- * native file descriptor and do the OS read() ourselves
- */
- apr_os_file_get(&fd, pod->pod_in);
- rc = read(fd, &c, 1);
- if (rc == 1) {
- switch(c) {
- case RESTART_CHAR:
- return AP_RESTART;
- case GRACEFUL_CHAR:
- return AP_GRACEFUL;
- }
- }
- return AP_NORESTART;
-}
-
-AP_DECLARE(apr_status_t) ap_worker_pod_close(ap_worker_pod_t *pod)
-{
- apr_status_t rv;
-
- rv = apr_file_close(pod->pod_out);
- if (rv != APR_SUCCESS) {
- return rv;
- }
-
- rv = apr_file_close(pod->pod_in);
- if (rv != APR_SUCCESS) {
- return rv;
- }
- return rv;
-}
-
-static apr_status_t pod_signal_internal(ap_worker_pod_t *pod, int graceful)
-{
- apr_status_t rv;
- char char_of_death = graceful ? GRACEFUL_CHAR : RESTART_CHAR;
- apr_size_t one = 1;
-
- rv = apr_file_write(pod->pod_out, &char_of_death, &one);
- if (rv != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_WARNING, rv, ap_server_conf, APLOGNO(00325)
- "write pipe_of_death");
- }
- return rv;
-}
-
-AP_DECLARE(apr_status_t) ap_worker_pod_signal(ap_worker_pod_t *pod, int graceful)
-{
- return pod_signal_internal(pod, graceful);
-}
-
-AP_DECLARE(void) ap_worker_pod_killpg(ap_worker_pod_t *pod, int num, int graceful)
-{
- int i;
- apr_status_t rv = APR_SUCCESS;
-
- for (i = 0; i < num && rv == APR_SUCCESS; i++) {
- rv = pod_signal_internal(pod, graceful);
- }
-}
-
+++ /dev/null
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @file worker/pod.h
- * @brief Worker MPM Pipe of Death
- *
- * @addtogroup APACHE_MPM_WORKER
- * @{
- */
-
-#include "apr.h"
-#include "apr_strings.h"
-#define APR_WANT_STRFUNC
-#include "apr_want.h"
-
-#include "httpd.h"
-#include "http_config.h"
-#include "http_log.h"
-#include "http_main.h"
-#include "mpm_common.h"
-#include "ap_mpm.h"
-#include "ap_listen.h"
-#include "mpm_default.h"
-
-#define RESTART_CHAR '$'
-#define GRACEFUL_CHAR '!'
-
-#define AP_RESTART 0
-#define AP_GRACEFUL 1
-
-typedef struct ap_worker_pod_t ap_worker_pod_t;
-
-struct ap_worker_pod_t {
- apr_file_t *pod_in;
- apr_file_t *pod_out;
- apr_pool_t *p;
-};
-
-AP_DECLARE(apr_status_t) ap_worker_pod_open(apr_pool_t *p, ap_worker_pod_t **pod);
-AP_DECLARE(int) ap_worker_pod_check(ap_worker_pod_t *pod);
-AP_DECLARE(apr_status_t) ap_worker_pod_close(ap_worker_pod_t *pod);
-AP_DECLARE(apr_status_t) ap_worker_pod_signal(ap_worker_pod_t *pod, int graceful);
-AP_DECLARE(void) ap_worker_pod_killpg(ap_worker_pod_t *pod, int num, int graceful);
-/** @} */
#include "http_core.h" /* for get_remote_host */
#include "http_connection.h"
#include "ap_mpm.h"
-#include "pod.h"
#include "mpm_common.h"
#include "ap_listen.h"
#include "scoreboard.h"
#define ID_FROM_CHILD_THREAD(c, t) ((c * thread_limit) + t)
-static ap_worker_pod_t *pod;
+static ap_pod_t *pod;
/* The worker MPM respects a couple of runtime flags that can aid
* in debugging. Setting the -DNO_DETACH flag will prevent the root process
apr_signal(SIGTERM, dummy_signal_handler);
/* Watch for any messages from the parent over the POD */
while (1) {
- rv = ap_worker_pod_check(pod);
- if (rv == AP_NORESTART) {
+ rv = ap_mpm_podx_check(pod);
+ if (rv == AP_MPM_PODX_NORESTART) {
/* see if termination was triggered while we slept */
switch(terminate_mode) {
case ST_GRACEFUL:
- rv = AP_GRACEFUL;
+ rv = AP_MPM_PODX_GRACEFUL;
break;
case ST_UNGRACEFUL:
- rv = AP_RESTART;
+ rv = AP_MPM_PODX_RESTART;
break;
}
}
- if (rv == AP_GRACEFUL || rv == AP_RESTART) {
+ if (rv == AP_MPM_PODX_GRACEFUL || rv == AP_MPM_PODX_RESTART) {
/* make sure the start thread has finished;
* signal_threads() and join_workers depend on that
*/
join_start_thread(start_thread_id);
- signal_threads(rv == AP_GRACEFUL ? ST_GRACEFUL : ST_UNGRACEFUL);
+ signal_threads(rv == AP_MPM_PODX_GRACEFUL ? ST_GRACEFUL : ST_UNGRACEFUL);
break;
}
}
if (idle_thread_count > max_spare_threads) {
/* Kill off one child */
- ap_worker_pod_signal(pod, TRUE);
+ ap_mpm_podx_signal(pod, AP_MPM_PODX_GRACEFUL);
retained->idle_spawn_rate = 1;
}
else if (idle_thread_count < min_spare_threads) {
/* Time to shut down:
* Kill child processes, tell them to call child_exit, etc...
*/
- ap_worker_pod_killpg(pod, ap_daemons_limit, FALSE);
+ ap_mpm_podx_killpg(pod, ap_daemons_limit, AP_MPM_PODX_RESTART);
ap_reclaim_child_processes(1, /* Start with SIGTERM */
worker_note_child_killed);
/* Close our listeners, and then ask our children to do same */
ap_close_listeners();
- ap_worker_pod_killpg(pod, ap_daemons_limit, TRUE);
+ ap_mpm_podx_killpg(pod, ap_daemons_limit, AP_MPM_PODX_GRACEFUL);
ap_relieve_child_processes(worker_note_child_killed);
if (!child_fatal) {
* way, try and make sure that all of our processes are
* really dead.
*/
- ap_worker_pod_killpg(pod, ap_daemons_limit, FALSE);
+ ap_mpm_podx_killpg(pod, ap_daemons_limit, AP_MPM_PODX_RESTART);
ap_reclaim_child_processes(1, worker_note_child_killed);
return DONE;
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf, APLOGNO(00297)
AP_SIG_GRACEFUL_STRING " received. Doing graceful restart");
/* wake up the children...time to die. But we'll have more soon */
- ap_worker_pod_killpg(pod, ap_daemons_limit, TRUE);
+ ap_mpm_podx_killpg(pod, ap_daemons_limit, AP_MPM_PODX_GRACEFUL);
/* This is mostly for debugging... so that we know what is still
* and a SIGHUP, we may as well use the same signal, because some user
* pthreads are stealing signals from us left and right.
*/
- ap_worker_pod_killpg(pod, ap_daemons_limit, FALSE);
+ ap_mpm_podx_killpg(pod, ap_daemons_limit, AP_MPM_PODX_RESTART);
ap_reclaim_child_processes(1, /* Start with SIGTERM */
worker_note_child_killed);
}
if (!one_process) {
- if ((rv = ap_worker_pod_open(pconf, &pod))) {
+ if ((rv = ap_mpm_podx_open(pconf, &pod))) {
ap_log_error(APLOG_MARK, APLOG_CRIT | level_flags, rv,
(startup ? NULL : s),
"could not open pipe-of-death");
return rv;
}
+AP_DECLARE(apr_status_t) ap_mpm_podx_open(apr_pool_t *p, ap_pod_t **pod)
+{
+ apr_status_t rv;
+
+ *pod = apr_palloc(p, sizeof(**pod));
+ rv = apr_file_pipe_create(&((*pod)->pod_in), &((*pod)->pod_out), p);
+ if (rv != APR_SUCCESS) {
+ return rv;
+ }
+ /*
+ apr_file_pipe_timeout_set((*pod)->pod_in, 0);
+ */
+ (*pod)->p = p;
+
+ /* close these before exec. */
+ apr_file_inherit_unset((*pod)->pod_in);
+ apr_file_inherit_unset((*pod)->pod_out);
+
+ return APR_SUCCESS;
+}
+
+AP_DECLARE(int) ap_mpm_podx_check(ap_pod_t *pod)
+{
+ char c;
+ apr_os_file_t fd;
+ int rc;
+
+ /* we need to surface EINTR so we'll have to grab the
+ * native file descriptor and do the OS read() ourselves
+ */
+ apr_os_file_get(&fd, pod->pod_in);
+ rc = read(fd, &c, 1);
+ if (rc == 1) {
+ switch (c) {
+ case AP_MPM_PODX_RESTART_CHAR:
+ return AP_MPM_PODX_RESTART;
+ case AP_MPM_PODX_GRACEFUL_CHAR:
+ return AP_MPM_PODX_GRACEFUL;
+ }
+ }
+ return AP_MPM_PODX_NORESTART;
+}
+
+AP_DECLARE(apr_status_t) ap_mpm_podx_close(ap_pod_t *pod)
+{
+ apr_status_t rv;
+
+ rv = apr_file_close(pod->pod_out);
+ if (rv != APR_SUCCESS) {
+ return rv;
+ }
+
+ rv = apr_file_close(pod->pod_in);
+ if (rv != APR_SUCCESS) {
+ return rv;
+ }
+ return rv;
+}
+
+static apr_status_t podx_signal_internal(ap_pod_t *pod,
+ ap_podx_restart_t graceful)
+{
+ apr_status_t rv;
+ apr_size_t one = 1;
+ char char_of_death = ' ';
+ switch (graceful) {
+ case AP_MPM_PODX_RESTART:
+ char_of_death = AP_MPM_PODX_RESTART_CHAR;
+ break;
+ case AP_MPM_PODX_GRACEFUL:
+ char_of_death = AP_MPM_PODX_GRACEFUL_CHAR;
+ break;
+ case AP_MPM_PODX_NORESTART:
+ break;
+ }
+
+ rv = apr_file_write(pod->pod_out, &char_of_death, &one);
+ if (rv != APR_SUCCESS) {
+ ap_log_error(APLOG_MARK, APLOG_WARNING, rv, ap_server_conf, APLOGNO(2404)
+ "write pipe_of_death");
+ }
+ return rv;
+}
+
+AP_DECLARE(apr_status_t) ap_mpm_podx_signal(ap_pod_t * pod,
+ ap_podx_restart_t graceful)
+{
+ return podx_signal_internal(pod, graceful);
+}
+
+AP_DECLARE(void) ap_mpm_podx_killpg(ap_pod_t * pod, int num,
+ ap_podx_restart_t graceful)
+{
+ int i;
+ apr_status_t rv = APR_SUCCESS;
+
+ for (i = 0; i < num && rv == APR_SUCCESS; i++) {
+ rv = podx_signal_internal(pod, graceful);
+ }
+}
+
/* This function connects to the server and sends enough data to
* ensure the child wakes up and processes a new connection. This
* permits the MPM to skip the poll when there is only one listening