]> granicus.if.org Git - apache/commitdiff
Port reliable piped logs to mpmt_pthread and dexter. Also a couple of small
authorRyan Bloom <rbb@apache.org>
Thu, 4 May 2000 19:42:57 +0000 (19:42 +0000)
committerRyan Bloom <rbb@apache.org>
Thu, 4 May 2000 19:42:57 +0000 (19:42 +0000)
cleanups for reliable piped logs.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@85137 13f79535-47bb-0310-9956-ffa450edef68

server/log.c
server/mpm/dexter/dexter.c
server/mpm/mpmt_pthread/mpmt_pthread.c
server/mpm/mpmt_pthread/scoreboard.c
server/mpm/mpmt_pthread/scoreboard.h
server/mpm/prefork/prefork.c
support/apxs.in

index 2d3e87f7ca87bfbcb4831ae43bc43fbda32953c7..3ccf6b4fde00b4a92b1e0be287bed295da696472 100644 (file)
@@ -636,6 +636,13 @@ static void piped_log_maintenance(int reason, void *data, ap_wait_t status)
 
     switch (reason) {
     case APR_OC_REASON_DEATH:
+       pl->pid = NULL;
+       ap_unregister_other_child(pl);
+       if (pl->program == NULL) {
+           /* during a restart */
+           break;
+       }
+        break;
     case APR_OC_REASON_LOST:
        pl->pid = NULL;
        ap_unregister_other_child(pl);
index 0f04013bc0273b6b6f30fe7f795bc85e570d0a20..933482bc07edb1f259341df6a5dd6fcfde62be1c 100644 (file)
@@ -275,29 +275,35 @@ static void reclaim_child_processes(int terminate)
 #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;
+        wait_or_timeout_counter = 0;
 #ifdef APR_HAS_OTHER_CHILD
-       probe_writable_fds();
+        ap_probe_writable_fds();
 #endif
     }
-    ret = waitpid(-1, status, WNOHANG);
-    if (ret == -1 && errno == EINTR) {
-       return -1;
+    rv = ap_wait_all_procs(&ret, APR_NOWAIT, p);
+    if (ap_canonical_error(rv) == APR_EINTR) {
+        return NULL;
     }
-    if (ret > 0) {
-       return ret;
+    if (rv == APR_CHILD_DONE) {
+        return ret;
     }
+#ifdef NEED_WAITPID
+    if ((ret = reap_children(status)) > 0) {
+        return ret;
+    }
+#endif
     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 */
@@ -489,8 +495,10 @@ static void set_signals(void)
 #endif
 }
 
-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.
        */
@@ -1077,19 +1085,21 @@ static void server_main_loop(int remaining_children_to_start)
 {
     int child_slot;
     ap_wait_t status;
-    int pid;
+    ap_proc_t *pid;
     int i;
 
     while (!restart_pending && !shutdown_pending) {
-        pid = wait_or_timeout(&status);
+        pid = wait_or_timeout(&status, pconf);
         
-        if (pid >= 0) {
+        if (pid != NULL) {
+            int actual_pid;
+            ap_get_os_proc(&actual_pid, pid);
             process_child_status(pid, status);
             /* non-fatal death... note that it's gone in the child table and
              * clean out the status table. */
             child_slot = -1;
             for (i = 0; i < max_daemons_limit; ++i) {
-               if (child_table[i].pid == pid) {
+               if (child_table[i].pid == actual_pid) {
                     int j;
 
                     child_slot = i;
@@ -1112,7 +1122,7 @@ static void server_main_loop(int remaining_children_to_start)
                }
 #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 59604438ea2b5889cfb2814ed88547fde1cafd5e..e78d354a0bba50a98d9a1ee4ff6a8649f07350b4 100644 (file)
@@ -271,29 +271,35 @@ static void reclaim_child_processes(int terminate)
 #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;
+        wait_or_timeout_counter = 0;
 #ifdef APR_HAS_OTHER_CHILD
-       probe_writable_fds();
+        ap_probe_writable_fds();
 #endif
     }
-    ret = waitpid(-1, status, WNOHANG);
-    if (ret == -1 && errno == EINTR) {
-       return -1;
+    rv = ap_wait_all_procs(&ret, APR_NOWAIT, p);
+    if (ap_canonical_error(rv) == APR_EINTR) {
+        return NULL;
     }
-    if (ret > 0) {
-       return ret;
+    if (rv == APR_CHILD_DONE) {
+        return ret;
     }
+#ifdef NEED_WAITPID
+    if ((ret = reap_children(status)) > 0) {
+        return ret;
+    }
+#endif
     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 */
@@ -486,8 +492,10 @@ static void set_signals(void)
 #endif
 }
 
-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.
        */
@@ -1110,13 +1118,14 @@ static void server_main_loop(int remaining_children_to_start)
 {
     int child_slot;
     ap_wait_t status;
-    int pid;
+    ap_proc_t *pid;
     int i;
 
     while (!restart_pending && !shutdown_pending) {
-        pid = wait_or_timeout(&status);
+        /* this is a memory leak, but I'll fix it later. */
+        pid = wait_or_timeout(&status, pconf);
         
-        if (pid >= 0) {
+        if (pid != NULL) {
             process_child_status(pid, status);
             /* non-fatal death... note that it's gone in the scoreboard. */
             child_slot = find_child_by_pid(pid);
@@ -1135,7 +1144,7 @@ static void server_main_loop(int remaining_children_to_start)
                }
 #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 f112c5ce5885ffaeb857cdf28a1fd8153f7d0431..8a1a1d7dfddb6dc91d988e3103f9a79970e85b2a 100644 (file)
@@ -201,13 +201,16 @@ void increment_counts(int child_num, int thread_num, request_rec *r)
 
 }
 
-API_EXPORT(int) find_child_by_pid(int pid)
+API_EXPORT(int) find_child_by_pid(ap_proc_t *pid)
 {
     int i;
+    int actual_pid;
+
     int max_daemons_limit = ap_get_max_daemons();
+    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;
index c601d4804f1bee63a07b658c79630fdde44a3e12..9d64c9a1914294924875bb36e6daf76d47e96df6 100644 (file)
@@ -234,7 +234,7 @@ API_EXPORT(void) reopen_scoreboard(ap_pool_t *p);
 ap_inline void ap_sync_scoreboard_image(void);
 void increment_counts(int child_num, int thread_num, request_rec *r);
 void update_scoreboard_global(void);
-API_EXPORT(int) find_child_by_pid(int pid);
+API_EXPORT(int) find_child_by_pid(ap_proc_t *pid);
 int ap_update_child_status(int child_num, int thread_num, int status, request_rec *r);
 void ap_time_process_request(int child_num, int thread_num, int status);
 
index 052a76a50353c0ee09a37de00288d72af8dbe1ec..61b9e02f76027d15d228b0b9c3482a6dc24dadc5 100644 (file)
@@ -1162,8 +1162,8 @@ static ap_proc_t *wait_or_timeout(ap_wait_t *status, ap_pool_t *p)
        ap_probe_writable_fds();
 #endif
     }
-    rv = ap_wait_all_procs(&ret, WNOHANG, p);
-    if (rv != -1 && rv == APR_CHILD_NOTDONE) {
+    rv = ap_wait_all_procs(&ret, APR_NOWAIT, p);
+    if (ap_canonical_error(rv) == APR_EINTR) {
        return NULL;
     }
     if (rv == APR_CHILD_DONE) {
index eb3e2d184a779d1a423ea907f0ebeff9d0aa8fbc..9320b051684a1c5cf345858bbc84bdd7d0456e69 100644 (file)
@@ -1,4 +1,4 @@
-#!/usr/local/bin/perl
+#!/usr/bin/perl
 # ====================================================================
 # The Apache Software License, Version 1.1
 #