httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r1409214 - in /httpd/httpd/trunk: docs/log-message-tags/ include/ server/ server/mpm/event/ server/mpm/eventopt/ server/mpm/worker/
Date Wed, 14 Nov 2012 14:26:28 GMT
Author: jim
Date: Wed Nov 14 14:26:26 2012
New Revision: 1409214

URL: http://svn.apache.org/viewvc?rev=1409214&view=rev
Log:
Pull out the "extended" pod functions used by event and worker
to core, since it will be used by Simple and Lean and
likely other MPMs. Avoid duplication.

Removed:
    httpd/httpd/trunk/server/mpm/event/pod.c
    httpd/httpd/trunk/server/mpm/event/pod.h
    httpd/httpd/trunk/server/mpm/eventopt/pod.c
    httpd/httpd/trunk/server/mpm/eventopt/pod.h
    httpd/httpd/trunk/server/mpm/worker/pod.c
    httpd/httpd/trunk/server/mpm/worker/pod.h
Modified:
    httpd/httpd/trunk/docs/log-message-tags/next-number
    httpd/httpd/trunk/include/mpm_common.h
    httpd/httpd/trunk/server/mpm/event/config3.m4
    httpd/httpd/trunk/server/mpm/event/event.c
    httpd/httpd/trunk/server/mpm/eventopt/config3.m4
    httpd/httpd/trunk/server/mpm/eventopt/eventopt.c
    httpd/httpd/trunk/server/mpm/worker/config3.m4
    httpd/httpd/trunk/server/mpm/worker/worker.c
    httpd/httpd/trunk/server/mpm_unix.c

Modified: httpd/httpd/trunk/docs/log-message-tags/next-number
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/log-message-tags/next-number?rev=1409214&r1=1409213&r2=1409214&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/log-message-tags/next-number (original)
+++ httpd/httpd/trunk/docs/log-message-tags/next-number Wed Nov 14 14:26:26 2012
@@ -1 +1 @@
-2404
+2405

Modified: httpd/httpd/trunk/include/mpm_common.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/mpm_common.h?rev=1409214&r1=1409213&r2=1409214&view=diff
==============================================================================
--- httpd/httpd/trunk/include/mpm_common.h (original)
+++ httpd/httpd/trunk/include/mpm_common.h Wed Nov 14 14:26:26 2012
@@ -278,6 +278,50 @@ AP_DECLARE(apr_status_t) ap_mpm_pod_sign
  */
 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 extended 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 */
 
 /**

Modified: httpd/httpd/trunk/server/mpm/event/config3.m4
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/event/config3.m4?rev=1409214&r1=1409213&r2=1409214&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/event/config3.m4 (original)
+++ httpd/httpd/trunk/server/mpm/event/config3.m4 Wed Nov 14 14:26:26 2012
@@ -8,7 +8,7 @@ if test "$ac_cv_serf" = yes ; then
 fi
 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)])
 

Modified: httpd/httpd/trunk/server/mpm/event/event.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/event/event.c?rev=1409214&r1=1409213&r2=1409214&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/event/event.c (original)
+++ httpd/httpd/trunk/server/mpm/event/event.c Wed Nov 14 14:26:26 2012
@@ -338,7 +338,7 @@ static event_retained_data *retained;
 
 #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
@@ -2257,25 +2257,25 @@ static void child_main(int child_num_arg
         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;
             }
         }
@@ -2504,7 +2504,7 @@ static void perform_idle_server_maintena
 
     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) {
@@ -2735,7 +2735,7 @@ static int event_run(apr_pool_t * _pconf
         /* 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);
 
@@ -2756,7 +2756,7 @@ static int event_run(apr_pool_t * _pconf
 
         /* 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) {
@@ -2796,7 +2796,7 @@ static int event_run(apr_pool_t * _pconf
          * 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;
@@ -2822,7 +2822,7 @@ static int event_run(apr_pool_t * _pconf
                      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
@@ -2835,7 +2835,7 @@ static int event_run(apr_pool_t * _pconf
          * 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);
@@ -2872,7 +2872,7 @@ static int event_open_logs(apr_pool_t * 
     }
 
     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");

Modified: httpd/httpd/trunk/server/mpm/eventopt/config3.m4
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/eventopt/config3.m4?rev=1409214&r1=1409213&r2=1409214&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/eventopt/config3.m4 (original)
+++ httpd/httpd/trunk/server/mpm/eventopt/config3.m4 Wed Nov 14 14:26:26 2012
@@ -6,6 +6,6 @@ if test "$ac_cv_serf" = yes ; then
 fi
 APACHE_SUBST(MOD_MPM_EVENTOPT_LDADD)
 
-APACHE_MPM_MODULE(eventopt, $enable_mpm_eventopt, eventopt.lo fdqueue.lo equeue.lo pod.lo,[
+APACHE_MPM_MODULE(eventopt, $enable_mpm_eventopt, eventopt.lo fdqueue.lo equeue.lo,[
     AC_CHECK_FUNCS(pthread_kill)
 ], , [\$(MOD_MPM_EVENTOPT_LDADD)])

Modified: httpd/httpd/trunk/server/mpm/eventopt/eventopt.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/eventopt/eventopt.c?rev=1409214&r1=1409213&r2=1409214&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/eventopt/eventopt.c (original)
+++ httpd/httpd/trunk/server/mpm/eventopt/eventopt.c Wed Nov 14 14:26:26 2012
@@ -347,7 +347,7 @@ static event_retained_data *retained;
 
 #define ID_FROM_CHILD_THREAD(c, t)    ((c * thread_limit) + t)
 
-static ap_eventopt_pod_t *pod;
+static ap_pod_t *pod;
 
 /* The eventopt MPM respects a couple of runtime flags that can aid
  * in debugging. Setting the -DNO_DETACH flag will prevent the root process
@@ -2245,25 +2245,25 @@ static void child_main(int child_num_arg
         apr_signal(SIGTERM, dummy_signal_handler);
         /* Watch for any messages from the parent over the POD */
         while (1) {
-            rv = ap_eventopt_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;
             }
         }
@@ -2485,7 +2485,7 @@ static void perform_idle_server_maintena
 
     if (idle_thread_count > max_spare_threads) {
         /* Kill off one child */
-        ap_eventopt_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) {
@@ -2711,7 +2711,7 @@ static int event_run(apr_pool_t * _pconf
         /* Time to shut down:
          * Kill child processes, tell them to call child_exit, etc...
          */
-        ap_eventopt_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);
 
@@ -2732,7 +2732,7 @@ static int event_run(apr_pool_t * _pconf
 
         /* Close our listeners, and then ask our children to do same */
         ap_close_listeners();
-        ap_eventopt_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) {
@@ -2772,7 +2772,7 @@ static int event_run(apr_pool_t * _pconf
          * way, try and make sure that all of our processes are
          * really dead.
          */
-        ap_eventopt_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;
@@ -2798,7 +2798,7 @@ static int event_run(apr_pool_t * _pconf
                      AP_SIG_GRACEFUL_STRING
                      " received.  Doing graceful restart");
         /* wake up the children...time to die.  But we'll have more soon */
-        ap_eventopt_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
@@ -2811,7 +2811,7 @@ static int event_run(apr_pool_t * _pconf
          * and a SIGHUP, we may as well use the same signal, because some user
          * pthreads are stealing signals from us left and right.
          */
-        ap_eventopt_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);
@@ -2848,7 +2848,7 @@ static int event_open_logs(apr_pool_t * 
     }
 
     if (!one_process) {
-        if ((rv = ap_eventopt_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");

Modified: httpd/httpd/trunk/server/mpm/worker/config3.m4
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/worker/config3.m4?rev=1409214&r1=1409213&r2=1409214&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/worker/config3.m4 (original)
+++ httpd/httpd/trunk/server/mpm/worker/config3.m4 Wed Nov 14 14:26:26 2012
@@ -1,7 +1,7 @@
 APACHE_MPMPATH_INIT(worker)
 
 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)
 ])
 

Modified: httpd/httpd/trunk/server/mpm/worker/worker.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/worker/worker.c?rev=1409214&r1=1409213&r2=1409214&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/worker/worker.c (original)
+++ httpd/httpd/trunk/server/mpm/worker/worker.c Wed Nov 14 14:26:26 2012
@@ -189,7 +189,7 @@ typedef struct {
 
 #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
@@ -1330,15 +1330,15 @@ static void child_main(int child_num_arg
         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;
                 }
             }
@@ -1347,7 +1347,7 @@ static void child_main(int child_num_arg
                  * 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;
             }
         }
@@ -1572,7 +1572,7 @@ static void perform_idle_server_maintena
 
     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) {
@@ -1827,7 +1827,7 @@ static int worker_run(apr_pool_t *_pconf
         /* 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);
 
@@ -1848,7 +1848,7 @@ static int worker_run(apr_pool_t *_pconf
 
         /* 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) {
@@ -1888,7 +1888,7 @@ static int worker_run(apr_pool_t *_pconf
          * 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;
@@ -1913,7 +1913,7 @@ static int worker_run(apr_pool_t *_pconf
         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
@@ -1926,7 +1926,7 @@ static int worker_run(apr_pool_t *_pconf
          * 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);
@@ -1962,7 +1962,7 @@ static int worker_open_logs(apr_pool_t *
     }
 
     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");

Modified: httpd/httpd/trunk/server/mpm_unix.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm_unix.c?rev=1409214&r1=1409213&r2=1409214&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm_unix.c (original)
+++ httpd/httpd/trunk/server/mpm_unix.c Wed Nov 14 14:26:26 2012
@@ -501,6 +501,107 @@ static apr_status_t pod_signal_internal(
     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



Mime
View raw message