]> granicus.if.org Git - apache/commitdiff
Make reliable piped logs work on 2.0.
authorRyan Bloom <rbb@apache.org>
Thu, 4 May 2000 04:02:37 +0000 (04:02 +0000)
committerRyan Bloom <rbb@apache.org>
Thu, 4 May 2000 04:02:37 +0000 (04:02 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@85136 13f79535-47bb-0310-9956-ffa450edef68

STATUS
include/ap_mpm.h
modules/generators/mod_cgid.c
server/log.c
server/main.c
server/mpm/dexter/dexter.c
server/mpm/mpmt_beos/mpmt_beos.c
server/mpm/mpmt_pthread/mpmt_pthread.c
server/mpm/prefork/prefork.c
server/mpm/spmt_os2/spmt_os2.c
support/rotatelogs.c

diff --git a/STATUS b/STATUS
index 183211c0db6710004e7d98ae6098c42aab830be1..dda894e74467768cf143e34f70a5b56eebbc98e3 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -1,5 +1,5 @@
 Apache 2.0 STATUS:
-Last modified at [$Date: 2000/05/01 21:52:18 $]
+Last modified at [$Date: 2000/05/04 04:02:10 $]
 
 Release:
 
@@ -31,11 +31,6 @@ RELEASE SHOWSTOPPERS:
         http_connection.c and into the MPMs.
        Status:
 
-    * Reliable piped logs look broken everywhere. Each MPM includes essentially
-       identical code to ap_register_other_child(), etc. Most of this code can
-       be moved out of the MPMs and into some common file (http_core.c?).
-       Dean says presumably you mean an os-specific file?
-
     * Put back resource limit code
 
     * suEXEC doesn't work
index 73ee7e30145a24e16f5b5dfa6c9a79608e591713..d4a4d341ded3217260cb0c8727b93489aee11f2f 100644 (file)
@@ -130,44 +130,4 @@ void ap_start_restart(int graceful);
  */
 void ap_signal_parent(ap_pool_t *p, const char* signal, const char* server_root);
 
-#ifdef HAS_OTHER_CHILD
-/*
- * register an other_child -- a child which the main loop keeps track of
- * and knows it is different than the rest of the scoreboard.
- *
- * pid is the pid of the child.
- *
- * maintenance is a function that is invoked with a reason, the data
- * pointer passed here, and when appropriate a status result from waitpid().
- *
- * write_fd is an fd that is probed for writing by select() if it is ever
- * unwritable, then maintenance is invoked with reason OC_REASON_UNWRITABLE.
- * This is useful for log pipe children, to know when they've blocked.  To
- * disable this feature, use -1 for write_fd.
- */
-API_EXPORT(void) ap_register_other_child(int pid,
-       void (*maintenance) (int reason, void *data, ap_wait_t status), void *data,
-                                     int write_fd);
-#define OC_REASON_DEATH                0       /* child has died, caller must call
-                                        * unregister still */
-#define OC_REASON_UNWRITABLE   1       /* write_fd is unwritable */
-#define OC_REASON_RESTART      2       /* a restart is occuring, perform
-                                        * any necessary cleanup (including
-                                        * sending a special signal to child)
-                                        */
-#define OC_REASON_UNREGISTER   3       /* unregister has been called, do
-                                        * whatever is necessary (including
-                                        * kill the child) */
-#define OC_REASON_LOST         4       /* somehow the child exited without
-                                        * us knowing ... buggy os? */
-
-/*
- * unregister an other_child.  Note that the data pointer is used here, and
- * is assumed to be unique per other_child.  This is because the pid and
- * write_fd are possibly killed off separately.
- */
-API_EXPORT(void) ap_unregister_other_child(void *data);
-
-#endif
-
 #endif
index 22275159c1d418a35dbc9fcde3b709cc0a87af54..1db51715bfe4cb467cbbe18bf0f4c6bb7cf94fb1 100644 (file)
@@ -299,7 +299,7 @@ static int call_exec(request_rec *r, char *argv0, char **env, int shellcmd)
 
 static void cgid_maint(int reason, void *data, ap_wait_t status)
 {
-#ifdef HAS_OTHER_CHILD
+#ifdef APR_HAS_OTHER_CHILD
     int *sd = data;
     switch (reason) {
         case OC_REASON_DEATH:
@@ -584,7 +584,7 @@ static void cgid_init(ap_pool_t *p, ap_pool_t *plog, ap_pool_t *ptemp, server_re
             cgid_server(main_server);
             exit(-1);
         } 
-#ifdef HAS_OTHER_CHILD
+#ifdef APR_HAS_OTHER_CHILD
         ap_register_other_child(pid, cgid_maint, &pid, -1);
 #endif
     } 
index e7f0b47ea7943a84e9959e537f32751d2d883414..2d3e87f7ca87bfbcb4831ae43bc43fbda32953c7 100644 (file)
@@ -594,15 +594,12 @@ static int piped_log_spawn(piped_log *pl)
     ap_os_proc_t pid;
     ap_proc_t *procnew;
 
-    /* pjr - calls to block and unblock alarms weren't here before, was this */
-    /*       an oversight or intentional?                                    */
-
 #ifdef SIGHUP
     ap_signal(SIGHUP, SIG_IGN);
 #endif
     if ((ap_createprocattr_init(&procattr, pl->p)         != APR_SUCCESS) ||
-        (ap_setprocattr_dir(procattr, pl->program)        != APR_SUCCESS) ||
-        (ap_set_childin(procattr, ap_piped_log_read_fd(pl), ap_piped_log_write_fd(pl)) != APR_SUCCESS)) {
+        (ap_setprocattr_childin(procattr, ap_piped_log_read_fd(pl), 
+                                ap_piped_log_write_fd(pl)) != APR_SUCCESS)) {
         /* Something bad happened, give up and go away. */
        ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
            "piped_log_spawn: unable to exec '%s': %s",
@@ -610,7 +607,13 @@ static int piped_log_spawn(piped_log *pl)
         rc = -1;
     }
     else {
-        rc = ap_create_process(&procnew, pl->program, NULL, NULL, procattr, pl->p);
+        char **args;
+        const char *pname;
+
+        ap_tokenize_to_argv(pl->program, &args, pl->p);
+        pname = ap_pstrdup(pl->p, args[0]);
+        rc = ap_create_process(&procnew, pname, args, NULL, procattr, pl->p);
     
         if (rc == APR_SUCCESS) {            
             /* pjr - This no longer happens inside the child, */
@@ -618,13 +621,11 @@ static int piped_log_spawn(piped_log *pl)
             /*   successful that the child is running.        */
             RAISE_SIGSTOP(PIPED_LOG_SPAWN); 
             pl->pid = procnew;
-            ap_get_os_proc(&pid, procnew);
-            ap_register_other_child(pid, piped_log_maintenance, pl, ap_piped_log_write_fd(pl));
+            ap_register_other_child(procnew, piped_log_maintenance, pl, 
+                                    ap_piped_log_write_fd(pl), pl->p);
         }
     }
     
-/*  ap_unblock_alarms(); */
-    
     return 0;
 }
 
@@ -634,8 +635,8 @@ static void piped_log_maintenance(int reason, void *data, ap_wait_t status)
     piped_log *pl = data;
 
     switch (reason) {
-    case OC_REASON_DEATH:
-    case OC_REASON_LOST:
+    case APR_OC_REASON_DEATH:
+    case APR_OC_REASON_LOST:
        pl->pid = NULL;
        ap_unregister_other_child(pl);
        if (pl->program == NULL) {
@@ -651,20 +652,20 @@ static void piped_log_maintenance(int reason, void *data, ap_wait_t status)
        }
        break;
     
-    case OC_REASON_UNWRITABLE:
+    case APR_OC_REASON_UNWRITABLE:
        if (pl->pid != NULL) {
            ap_kill(pl->pid, SIGTERM);
        }
        break;
     
-    case OC_REASON_RESTART:
+    case APR_OC_REASON_RESTART:
        pl->program = NULL;
        if (pl->pid != NULL) {
            ap_kill(pl->pid, SIGTERM);
        }
        break;
 
-    case OC_REASON_UNREGISTER:
+    case APR_OC_REASON_UNREGISTER:
        break;
     }
 }
@@ -706,6 +707,8 @@ API_EXPORT(piped_log *) ap_open_piped_log(ap_pool_t *p, const char *program)
        errno = save_errno;
        return NULL;
     }
+    ap_block_pipe(ap_piped_log_read_fd(pl));
+    ap_block_pipe(ap_piped_log_write_fd(pl));
     ap_register_cleanup(p, pl, piped_log_cleanup, piped_log_cleanup_for_exec);
     if (piped_log_spawn(pl) == -1) {
        int save_errno = errno;
index 68709998fd1e7f1e12ad39abc67aacb3529e9407..0e5f0b5c50e804ebcbf88b97948251c99026983f 100644 (file)
@@ -136,8 +136,8 @@ static void show_compile_settings(void)
 #ifdef SINGLE_LISTEN_UNSERIALIZED_ACCEPT
     printf(" -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT\n");
 #endif
-#ifdef HAS_OTHER_CHILD
-    printf(" -D HAS_OTHER_CHILD\n");
+#ifdef APR_HAS_OTHER_CHILD
+    printf(" -D APR_HAS_OTHER_CHILD\n");
 #endif
 #ifdef HAVE_RELIABLE_PIPED_LOGS
     printf(" -D HAVE_RELIABLE_PIPED_LOGS\n");
index b2f8d5cf7466bdea6d2c20fd5126a5cbf5406b5f..0f04013bc0273b6b6f30fe7f795bc85e570d0a20 100644 (file)
@@ -283,7 +283,7 @@ static int wait_or_timeout(ap_wait_t *status)
     ++wait_or_timeout_counter;
     if (wait_or_timeout_counter == INTERVAL_OF_WRITABLE_PROBES) {
        wait_or_timeout_counter = 0;
-#ifdef HAS_OTHER_CHILD
+#ifdef APR_HAS_OTHER_CHILD
        probe_writable_fds();
 #endif
     }
@@ -1110,7 +1110,7 @@ static void server_main_loop(int remaining_children_to_start)
                    make_child(server_conf, child_slot, time(NULL));
                    --remaining_children_to_start;
                }
-#ifdef HAS_OTHER_CHILD
+#ifdef APR_HAS_OTHER_CHILD
            }
            else if (reap_other_child(pid, status) == 0) {
                /* handled */
index f2f06ed542b83e75288ad3ca784abd5db209ecd7..5556a37fab83a2a24b41bd6fa87222d31896d9b3 100644 (file)
@@ -145,20 +145,6 @@ static int one_process = 0;
 int raise_sigstop_flags;
 #endif
 
-#ifdef HAS_OTHER_CHILD
-/* used to maintain list of children which aren't part of the scoreboard */
-typedef struct other_child_rec other_child_rec;
-struct other_child_rec {
-    other_child_rec *next;
-    int pid;
-    void (*maintenance) (int, void *, ap_wait_t);
-    void *data;
-    int write_fd;
-};
-static other_child_rec *other_children;
-#endif
-
-
 /* Global, alas, so http_core can talk to us */
 enum server_token_type ap_server_tokens = SrvTk_FULL;
 
@@ -182,117 +168,6 @@ void clean_child_exit(int code)
     exit(code);
 }
 
-/*****************************************************************
- * dealing with other children
- */
-
-#ifdef HAS_OTHER_CHILD
-API_EXPORT(void) ap_register_other_child(int pid,
-                      void (*maintenance) (int reason, void *, ap_wait_t status),
-                         void *data, int write_fd)
-{
-    other_child_rec *ocr;
-
-    ocr = ap_palloc(pconf, sizeof(*ocr));
-    ocr->pid = pid;
-    ocr->maintenance = maintenance;
-    ocr->data = data;
-    ocr->write_fd = write_fd;
-    ocr->next = other_children;
-    other_children = ocr;
-}
-
-/* note that since this can be called by a maintenance function while we're
- * scanning the other_children list, all scanners should protect themself
- * by loading ocr->next before calling any maintenance function.
- */
-API_EXPORT(void) ap_unregister_other_child(void *data)
-{
-    other_child_rec **pocr, *nocr;
-
-    for (pocr = &other_children; *pocr; pocr = &(*pocr)->next) {
-       if ((*pocr)->data == data) {
-           nocr = (*pocr)->next;
-           (*(*pocr)->maintenance) (OC_REASON_UNREGISTER, (*pocr)->data, -1);
-           *pocr = nocr;
-           /* XXX: um, well we've just wasted some space in pconf ? */
-           return;
-       }
-    }
-}
-
-/* test to ensure that the write_fds are all still writable, otherwise
- * invoke the maintenance functions as appropriate */
-static void probe_writable_fds(void)
-{
-    return;
-#if 0
-    fd_set writable_fds;
-    int fd_max;
-    other_child_rec *ocr, *nocr;
-    struct timeval tv;
-    int rc;
-
-    if (other_children == NULL)
-       return;
-
-    fd_max = 0;
-    FD_ZERO(&writable_fds);
-    do {
-       for (ocr = other_children; ocr; ocr = ocr->next) {
-           if (ocr->write_fd == -1)
-               continue;
-           FD_SET(ocr->write_fd, &writable_fds);
-           if (ocr->write_fd > fd_max) {
-               fd_max = ocr->write_fd;
-           }
-       }
-       if (fd_max == 0)
-           return;
-
-       tv.tv_sec = 0;
-       tv.tv_usec = 0;
-       rc = ap_select(fd_max + 1, NULL, &writable_fds, NULL, &tv);
-    } while (rc == -1 && errno == EINTR);
-
-    if (rc == -1) {
-       /* XXX: uhh this could be really bad, we could have a bad file
-        * descriptor due to a bug in one of the maintenance routines */
-       ap_log_unixerr("probe_writable_fds", "select",
-                   "could not probe writable fds", server_conf);
-       return;
-    }
-    if (rc == 0)
-       return;
-
-    for (ocr = other_children; ocr; ocr = nocr) {
-       nocr = ocr->next;
-       if (ocr->write_fd == -1)
-           continue;
-       if (FD_ISSET(ocr->write_fd, &writable_fds))
-           continue;
-       (*ocr->maintenance) (OC_REASON_UNWRITABLE, ocr->data, -1);
-    }
-#endif
-}
-
-/* possibly reap an other_child, return 0 if yes, -1 if not */
-static int reap_other_child(int pid, ap_wait_t status)
-{
-    other_child_rec *ocr, *nocr;
-
-    for (ocr = other_children; ocr; ocr = nocr) {
-       nocr = ocr->next;
-       if (ocr->pid != pid)
-           continue;
-       ocr->pid = -1;
-       (*ocr->maintenance) (OC_REASON_DEATH, ocr->data, status);
-       return 0;
-    }
-    return -1;
-}
-#endif
-
 static void reclaim_child_processes(int terminate)
 {
     int i, status;
@@ -300,9 +175,6 @@ static void reclaim_child_processes(int terminate)
     struct timeval tv;
     int waitret, tries;
     int not_dead_yet;
-#ifdef HAS_OTHER_CHILD
-    other_child_rec *ocr, *nocr;
-#endif
 
     for (tries = terminate ? 4 : 1; tries <= 9; ++tries) {
        /* don't want to hold up progress any more than 
@@ -364,28 +236,7 @@ static void reclaim_child_processes(int terminate)
                break;
            }
        }
-#ifdef HAS_OTHER_CHILD
-       for (ocr = other_children; ocr; ocr = nocr) {
-           nocr = ocr->next;
-           if (ocr->pid == -1)
-               continue;
-
-           waitret = waitpid(ocr->pid, &status, WNOHANG);
-           if (waitret == ocr->pid) {
-               ocr->pid = -1;
-               (*ocr->maintenance) (OC_REASON_DEATH, ocr->data, status);
-           }
-           else if (waitret == 0) {
-               (*ocr->maintenance) (OC_REASON_RESTART, ocr->data, -1);
-               ++not_dead_yet;
-           }
-           else if (waitret == -1) {
-               /* uh what the heck? they didn't call unregister? */
-               ocr->pid = -1;
-               (*ocr->maintenance) (OC_REASON_LOST, ocr->data, -1);
-           }
-       }
-#endif
+        ap_check_other_child();
        if (!not_dead_yet) {
            /* nothing left to wait for */
            break;
@@ -411,7 +262,7 @@ static int wait_or_timeout(ap_wait_t *status)
     ++wait_or_timeout_counter;
     if (wait_or_timeout_counter == INTERVAL_OF_WRITABLE_PROBES) {
        wait_or_timeout_counter = 0;
-#ifdef HAS_OTHER_CHILD
+#ifdef APR_HAS_OTHER_CHILD
        probe_writable_fds();
 #endif
     }
@@ -999,7 +850,7 @@ static void server_main_loop(int remaining_children_to_start)
                    make_child(server_conf, child_slot, time(NULL));
                    --remaining_children_to_start;
                }
-#ifdef HAS_OTHER_CHILD
+#ifdef APR_HAS_OTHER_CHILD
            }
            else if (reap_other_child(pid, status) == 0) {
                /* handled */
index 7f300c7db2ca1752b45ad7fc1baeb3c01adb6be1..59604438ea2b5889cfb2814ed88547fde1cafd5e 100644 (file)
@@ -279,7 +279,7 @@ static int wait_or_timeout(ap_wait_t *status)
     ++wait_or_timeout_counter;
     if (wait_or_timeout_counter == INTERVAL_OF_WRITABLE_PROBES) {
        wait_or_timeout_counter = 0;
-#ifdef HAS_OTHER_CHILD
+#ifdef APR_HAS_OTHER_CHILD
        probe_writable_fds();
 #endif
     }
@@ -1133,7 +1133,7 @@ static void server_main_loop(int remaining_children_to_start)
                    make_child(server_conf, child_slot, time(NULL));
                    --remaining_children_to_start;
                }
-#ifdef HAS_OTHER_CHILD
+#ifdef APR_HAS_OTHER_CHILD
            }
            else if (reap_other_child(pid, status) == 0) {
                /* handled */
index 3c68849ccaed199a644ed8ddf0258401336d724c..052a76a50353c0ee09a37de00288d72af8dbe1ec 100644 (file)
@@ -1014,12 +1014,14 @@ static void increment_counts(int child_num, request_rec *r)
 }
 */
 
-static int find_child_by_pid(int pid)
+static int find_child_by_pid(ap_proc_t *pid)
 {
     int i;
+    int actual_pid;
 
+    ap_get_os_proc(&actual_pid, pid);
     for (i = 0; i < max_daemons_limit; ++i)
-       if (ap_scoreboard_image->parent[i].pid == pid)
+       if (ap_scoreboard_image->parent[i].pid == actual_pid)
            return i;
 
     return -1;
@@ -1147,23 +1149,24 @@ int reap_children(ap_wait_t *status)
 #endif
 static int wait_or_timeout_counter;
 
-static int wait_or_timeout(ap_wait_t *status)
+static ap_proc_t *wait_or_timeout(ap_wait_t *status, ap_pool_t *p)
 {
     struct timeval tv;
-    int ret;
+    ap_status_t rv;
+    ap_proc_t *ret = NULL;
 
     ++wait_or_timeout_counter;
     if (wait_or_timeout_counter == INTERVAL_OF_WRITABLE_PROBES) {
        wait_or_timeout_counter = 0;
-#ifdef HAS_OTHER_CHILD
-       probe_writable_fds();
+#ifdef APR_HAS_OTHER_CHILD
+       ap_probe_writable_fds();
 #endif
     }
-    ret = waitpid(-1, status, WNOHANG);
-    if (ret == -1 && errno == EINTR) {
-       return -1;
+    rv = ap_wait_all_procs(&ret, WNOHANG, p);
+    if (rv != -1 && rv == APR_CHILD_NOTDONE) {
+       return NULL;
     }
-    if (ret > 0) {
+    if (rv == APR_CHILD_DONE) {
        return ret;
     }
 #ifdef NEED_WAITPID
@@ -1174,7 +1177,7 @@ static int wait_or_timeout(ap_wait_t *status)
     tv.tv_sec = SCOREBOARD_MAINTENANCE_INTERVAL / 1000000;
     tv.tv_usec = SCOREBOARD_MAINTENANCE_INTERVAL % 1000000;
     ap_select(0, NULL, NULL, NULL, &tv);
-    return -1;
+    return NULL;
 }
 
 /* handle all varieties of core dumping signals */
@@ -1937,8 +1940,10 @@ static void perform_idle_server_maintenance(void)
 }
 
 
-static void process_child_status(int pid, ap_wait_t status)
+static void process_child_status(ap_proc_t *abs_pid, ap_wait_t status)
 {
+    int pid;
+    ap_get_os_proc(&pid, abs_pid);
     /* Child died... if it died due to a fatal error,
        * we should simply bail out.
        */
@@ -2096,13 +2101,14 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s)
     while (!restart_pending && !shutdown_pending) {
        int child_slot;
        ap_wait_t status;
-       int pid = wait_or_timeout(&status);
+        /* this is a memory leak, but I'll fix it later. */
+       ap_proc_t *pid = wait_or_timeout(&status, pconf);
 
        /* XXX: if it takes longer than 1 second for all our children
         * to start up and get into IDLE state then we may spawn an
         * extra child
         */
-       if (pid >= 0) {
+       if (pid != NULL) {
            process_child_status(pid, status);
            /* non-fatal death... note that it's gone in the scoreboard. */
            ap_sync_scoreboard_image();
@@ -2119,9 +2125,9 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s)
                    make_child(server_conf, child_slot, time(0));
                    --remaining_children_to_start;
                }
-#ifdef HAS_OTHER_CHILD
+#ifdef APR_HAS_OTHER_CHILD
            }
-           else if (reap_other_child(pid, status) == 0) {
+           else if (ap_reap_other_child(pid, status) == 0) {
                /* handled */
 #endif
            }
index 3bf158c46a75fff5845593a2f4a6cd34557abac3..bf85505179952cfa9231934deb5389596ff8d880 100644 (file)
@@ -115,19 +115,6 @@ static server_rec *server_conf;
 
 static int one_process = 0;
 
-#ifdef HAS_OTHER_CHILD
-/* used to maintain list of children which aren't part of the scoreboard */
-typedef struct other_child_rec other_child_rec;
-struct other_child_rec {
-    other_child_rec *next;
-    int pid;
-    void (*maintenance) (int, void *, ap_wait_t);
-    void *data;
-    int write_fd;
-};
-static other_child_rec *other_children;
-#endif
-
 static ap_pool_t *pconf;               /* Pool for config stuff */
 static scoreboard *ap_scoreboard_image = NULL;
 
@@ -243,115 +230,6 @@ static void accept_mutex_off(void)
 #define SAFE_ACCEPT(stmt) do {stmt;} while(0)
 #endif
 
-
-/*****************************************************************
- * dealing with other children
- */
-
-#ifdef HAS_OTHER_CHILD
-API_EXPORT(void) ap_register_other_child(int pid,
-                      void (*maintenance) (int reason, void *, ap_wait_t status),
-                         void *data, int write_fd)
-{
-    other_child_rec *ocr;
-
-    ocr = ap_palloc(pconf, sizeof(*ocr));
-    ocr->pid = pid;
-    ocr->maintenance = maintenance;
-    ocr->data = data;
-    ocr->write_fd = write_fd;
-    ocr->next = other_children;
-    other_children = ocr;
-}
-
-/* note that since this can be called by a maintenance function while we're
- * scanning the other_children list, all scanners should protect themself
- * by loading ocr->next before calling any maintenance function.
- */
-API_EXPORT(void) ap_unregister_other_child(void *data)
-{
-    other_child_rec **pocr, *nocr;
-
-    for (pocr = &other_children; *pocr; pocr = &(*pocr)->next) {
-       if ((*pocr)->data == data) {
-           nocr = (*pocr)->next;
-           (*(*pocr)->maintenance) (OC_REASON_UNREGISTER, (*pocr)->data, -1);
-           *pocr = nocr;
-           /* XXX: um, well we've just wasted some space in pconf ? */
-           return;
-       }
-    }
-}
-
-/* test to ensure that the write_fds are all still writable, otherwise
- * invoke the maintenance functions as appropriate */
-static void probe_writable_fds(void)
-{
-    fd_set writable_fds;
-    int fd_max;
-    other_child_rec *ocr, *nocr;
-    struct timeval tv;
-    int rc;
-
-    if (other_children == NULL)
-       return;
-
-    fd_max = 0;
-    FD_ZERO(&writable_fds);
-    do {
-       for (ocr = other_children; ocr; ocr = ocr->next) {
-           if (ocr->write_fd == -1)
-               continue;
-           FD_SET(ocr->write_fd, &writable_fds);
-           if (ocr->write_fd > fd_max) {
-               fd_max = ocr->write_fd;
-           }
-       }
-       if (fd_max == 0)
-           return;
-
-       tv.tv_sec = 0;
-       tv.tv_usec = 0;
-       rc = ap_select(fd_max + 1, NULL, &writable_fds, NULL, &tv);
-    } while (rc == -1 && errno == EINTR);
-
-    if (rc == -1) {
-       /* XXX: uhh this could be really bad, we could have a bad file
-        * descriptor due to a bug in one of the maintenance routines */
-       ap_log_unixerr("probe_writable_fds", "select",
-                   "could not probe writable fds", server_conf);
-       return;
-    }
-    if (rc == 0)
-       return;
-
-    for (ocr = other_children; ocr; ocr = nocr) {
-       nocr = ocr->next;
-       if (ocr->write_fd == -1)
-           continue;
-       if (FD_ISSET(ocr->write_fd, &writable_fds))
-           continue;
-       (*ocr->maintenance) (OC_REASON_UNWRITABLE, ocr->data, -1);
-    }
-}
-
-/* possibly reap an other_child, return 0 if yes, -1 if not */
-static int reap_other_child(int pid, ap_wait_t status)
-{
-    other_child_rec *ocr, *nocr;
-
-    for (ocr = other_children; ocr; ocr = nocr) {
-       nocr = ocr->next;
-       if (ocr->pid != pid)
-           continue;
-       ocr->pid = -1;
-       (*ocr->maintenance) (OC_REASON_DEATH, ocr->data, status);
-       return 0;
-    }
-    return -1;
-}
-#endif
-
 API_EXPORT(int) ap_exists_scoreboard_image(void)
 {
     return (ap_scoreboard_image ? 1 : 0);
@@ -503,7 +381,7 @@ static int wait_or_timeout(ap_wait_t *status)
     ++wait_or_timeout_counter;
     if (wait_or_timeout_counter == INTERVAL_OF_WRITABLE_PROBES) {
        wait_or_timeout_counter = 0;
-#ifdef HAS_OTHER_CHILD
+#ifdef APR_HAS_OTHER_CHILD
        probe_writable_fds();
 #endif
     }
@@ -1483,7 +1361,7 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s)
                    make_child(server_conf, child_slot, time(0));
                    --remaining_children_to_start;
                }
-#ifdef HAS_OTHER_CHILD
+#ifdef APR_HAS_OTHER_CHILD
 /* TODO: this won't work, we waited on a thread not a process
            }
            else if (reap_other_child(pid, status) == 0) {
index d8316c606e950cfa0189a0ca183eedff9ac8ae6a..e49f0c0b69bff76a58ce1f4bb32b2f8e73dfdfc0 100644 (file)
@@ -72,8 +72,9 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
+#include <stdlib.h>
 
-int main (int argc, char **argv)
+int main (int argc, char *argv[])
 {
     char buf[BUFSIZE], buf2[MAX_PATH];
     time_t tLogEnd = 0;