]> granicus.if.org Git - apache/commitdiff
make mod_status a little faster by checking for an active server sooner in
authorJeff Trawick <trawick@apache.org>
Fri, 15 Mar 2002 12:04:58 +0000 (12:04 +0000)
committerJeff Trawick <trawick@apache.org>
Fri, 15 Mar 2002 12:04:58 +0000 (12:04 +0000)
the main loop

clean up the main loop by continuing when the server isn't active instead
of introducing yet another level of nesting

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

modules/generators/mod_status.c

index ac5a5488595c12d727d7761fa96b19dae054f4a2..3aecb4e2fc1fe046b8e944da996461e3c2f05031 100644 (file)
@@ -556,6 +556,13 @@ static int status_handler(request_rec *r)
         for (i = 0; i < server_limit; ++i) {
             for (j = 0; j < thread_limit; ++j) {
                 ws_record = ap_scoreboard_image->servers[i][j];
+
+                if (ws_record.access_count == 0 &&
+                    (ws_record.status == SERVER_READY ||
+                     ws_record.status == SERVER_DEAD)) {
+                    continue;
+                }
+
                 ps_record = ap_scoreboard_image->parent[i];
 
                 if (ws_record.start_time == 0L)
@@ -573,179 +580,176 @@ static int status_handler(request_rec *r)
                 my_bytes = ws_record.my_bytes_served;
                 conn_bytes = ws_record.conn_bytes;
 
-                if (lres != 0 || (ws_record.status != SERVER_READY
-                    && ws_record.status != SERVER_DEAD)) {
-                    if (!short_report) {
-                        if (no_table_report) {
-                            if (ws_record.status == SERVER_DEAD)
-                                ap_rprintf(r,
+                if (!short_report) {
+                    if (no_table_report) {
+                        if (ws_record.status == SERVER_DEAD)
+                            ap_rprintf(r,
                                        "<b>Server %d-%d</b> (-): %d|%lu|%lu [",
                                        i, (int)ps_record.generation,
                                        (int)conn_lres, my_lres, lres);
-                            else
-                                ap_rprintf(r,
-                                           "<b>Server %d-%d</b> (%"
-                                           APR_OS_PROC_T_FMT "): %d|%lu|%lu [",
-                                           i, (int) ps_record.generation,
-                                           ps_record.pid,
-                                           (int)conn_lres, my_lres, lres);
-
-                            switch (ws_record.status) {
-                            case SERVER_READY:
-                                ap_rputs("Ready", r);
-                                break;
-                            case SERVER_STARTING:
-                                ap_rputs("Starting", r);
-                                break;
-                            case SERVER_BUSY_READ:
-                                ap_rputs("<b>Read</b>", r);
-                                break;
-                            case SERVER_BUSY_WRITE:
-                                ap_rputs("<b>Write</b>", r);
-                                break;
-                            case SERVER_BUSY_KEEPALIVE:
-                                ap_rputs("<b>Keepalive</b>", r);
-                                break;
-                            case SERVER_BUSY_LOG:
-                                ap_rputs("<b>Logging</b>", r);
-                                break;
-                            case SERVER_BUSY_DNS:
-                                ap_rputs("<b>DNS lookup</b>", r);
-                                break;
-                            case SERVER_CLOSING:
-                                ap_rputs("<b>Closing</b>", r);
-                                break;
-                            case SERVER_DEAD:
-                                ap_rputs("Dead", r);
-                                break;
-                            case SERVER_GRACEFUL:
-                                ap_rputs("Graceful", r);
-                                break;
-                            case SERVER_IDLE_KILL:
-                                ap_rputs("Dying", r);
-                                break;
-                            default:
-                                ap_rputs("?STATE?", r);
-                                break;
-                            }
+                        else
+                            ap_rprintf(r,
+                                       "<b>Server %d-%d</b> (%"
+                                       APR_OS_PROC_T_FMT "): %d|%lu|%lu [",
+                                       i, (int) ps_record.generation,
+                                       ps_record.pid,
+                                       (int)conn_lres, my_lres, lres);
+                        
+                        switch (ws_record.status) {
+                        case SERVER_READY:
+                            ap_rputs("Ready", r);
+                            break;
+                        case SERVER_STARTING:
+                            ap_rputs("Starting", r);
+                            break;
+                        case SERVER_BUSY_READ:
+                            ap_rputs("<b>Read</b>", r);
+                            break;
+                        case SERVER_BUSY_WRITE:
+                            ap_rputs("<b>Write</b>", r);
+                            break;
+                        case SERVER_BUSY_KEEPALIVE:
+                            ap_rputs("<b>Keepalive</b>", r);
+                            break;
+                        case SERVER_BUSY_LOG:
+                            ap_rputs("<b>Logging</b>", r);
+                            break;
+                        case SERVER_BUSY_DNS:
+                            ap_rputs("<b>DNS lookup</b>", r);
+                            break;
+                        case SERVER_CLOSING:
+                            ap_rputs("<b>Closing</b>", r);
+                            break;
+                        case SERVER_DEAD:
+                            ap_rputs("Dead", r);
+                            break;
+                        case SERVER_GRACEFUL:
+                            ap_rputs("Graceful", r);
+                            break;
+                        case SERVER_IDLE_KILL:
+                            ap_rputs("Dying", r);
+                            break;
+                        default:
+                            ap_rputs("?STATE?", r);
+                            break;
+                        }
 #ifndef HAVE_TIMES
-                            /* Allow for OS/2 not having CPU stats */
-                            ap_rprintf(r, "]\n %.0f %ld (",
+                        /* Allow for OS/2 not having CPU stats */
+                        ap_rprintf(r, "]\n %.0f %ld (",
 #else
-                            ap_rprintf(r, "] u%g s%g cu%g cs%g\n %ld %ld (",
-                                       ws_record.times.tms_utime / tick,
-                                       ws_record.times.tms_stime / tick,
-                                       ws_record.times.tms_cutime / tick,
-                                       ws_record.times.tms_cstime / tick,
+                        ap_rprintf(r, "] u%g s%g cu%g cs%g\n %ld %ld (",
+                                   ws_record.times.tms_utime / tick,
+                                   ws_record.times.tms_stime / tick,
+                                   ws_record.times.tms_cutime / tick,
+                                   ws_record.times.tms_cstime / tick,
 #endif
-                                       (long)((nowtime - ws_record.last_used) /
-                                               APR_USEC_PER_SEC),
-                                       (long) req_time);
-
-                            format_byte_out(r, conn_bytes);
-                            ap_rputs("|", r);
-                            format_byte_out(r, my_bytes);
-                            ap_rputs("|", r);
-                            format_byte_out(r, bytes);
-                            ap_rputs(")\n", r);
+                                   (long)((nowtime - ws_record.last_used) /
+                                          APR_USEC_PER_SEC),
+                                   (long) req_time);
+
+                        format_byte_out(r, conn_bytes);
+                        ap_rputs("|", r);
+                        format_byte_out(r, my_bytes);
+                        ap_rputs("|", r);
+                        format_byte_out(r, bytes);
+                        ap_rputs(")\n", r);
+                        ap_rprintf(r,
+                                   " <i>%s {%s}</i> <b>[%s]</b><br />\n\n",
+                                   ap_escape_html(r->pool,
+                                                  ws_record.client),
+                                   ap_escape_html(r->pool,
+                                                  ws_record.request),
+                                   ap_escape_html(r->pool,
+                                                  ws_record.vhost));
+                    }
+                    else { /* !no_table_report */
+                        if (ws_record.status == SERVER_DEAD)
                             ap_rprintf(r,
-                                       " <i>%s {%s}</i> <b>[%s]</b><br />\n\n",
-                                       ap_escape_html(r->pool,
-                                                      ws_record.client),
-                                       ap_escape_html(r->pool,
-                                                      ws_record.request),
-                                       ap_escape_html(r->pool,
-                                                      ws_record.vhost));
+                                       "<tr><td><b>%d-%d</b></td><td>-</td><td>%d/%lu/%lu",
+                                       i, (int)ps_record.generation,
+                                       (int)conn_lres, my_lres, lres);
+                        else
+                            ap_rprintf(r,
+                                       "<tr><td><b>%d-%d</b></td><td>%"
+                                       APR_OS_PROC_T_FMT
+                                       "</td><td>%d/%lu/%lu",
+                                       i, (int)ps_record.generation,
+                                       ps_record.pid, (int)conn_lres,
+                                       my_lres, lres);
+
+                        switch (ws_record.status) {
+                        case SERVER_READY:
+                            ap_rputs("</td><td>_", r);
+                            break;
+                        case SERVER_STARTING:
+                            ap_rputs("</td><td><b>S</b>", r);
+                            break;
+                        case SERVER_BUSY_READ:
+                            ap_rputs("</td><td><b>R</b>", r);
+                            break;
+                        case SERVER_BUSY_WRITE:
+                            ap_rputs("</td><td><b>W</b>", r);
+                            break;
+                        case SERVER_BUSY_KEEPALIVE:
+                            ap_rputs("</td><td><b>K</b>", r);
+                            break;
+                        case SERVER_BUSY_LOG:
+                            ap_rputs("</td><td><b>L</b>", r);
+                            break;
+                        case SERVER_BUSY_DNS:
+                            ap_rputs("</td><td><b>D</b>", r);
+                            break;
+                        case SERVER_CLOSING:
+                            ap_rputs("</td><td><b>C</b>", r);
+                            break;
+                        case SERVER_DEAD:
+                            ap_rputs("</td><td>.", r);
+                            break;
+                        case SERVER_GRACEFUL:
+                            ap_rputs("</td><td>G", r);
+                            break;
+                        case SERVER_IDLE_KILL:
+                            ap_rputs("</td><td>I", r);
+                            break;
+                        default:
+                            ap_rputs("</td><td>?", r);
+                            break;
                         }
-                        else { /* !no_table_report */
-                            if (ws_record.status == SERVER_DEAD)
-                                ap_rprintf(r,
-                                           "<tr><td><b>%d-%d</b></td><td>-</td><td>%d/%lu/%lu",
-                                           i, (int)ps_record.generation,
-                                           (int)conn_lres, my_lres, lres);
-                            else
-                                ap_rprintf(r,
-                                           "<tr><td><b>%d-%d</b></td><td>%"
-                                           APR_OS_PROC_T_FMT
-                                           "</td><td>%d/%lu/%lu",
-                                           i, (int)ps_record.generation,
-                                           ps_record.pid, (int)conn_lres,
-                                           my_lres, lres);
-
-                            switch (ws_record.status) {
-                            case SERVER_READY:
-                                ap_rputs("</td><td>_", r);
-                                break;
-                            case SERVER_STARTING:
-                                ap_rputs("</td><td><b>S</b>", r);
-                                break;
-                            case SERVER_BUSY_READ:
-                                ap_rputs("</td><td><b>R</b>", r);
-                                break;
-                            case SERVER_BUSY_WRITE:
-                                ap_rputs("</td><td><b>W</b>", r);
-                                break;
-                            case SERVER_BUSY_KEEPALIVE:
-                                ap_rputs("</td><td><b>K</b>", r);
-                                break;
-                            case SERVER_BUSY_LOG:
-                                ap_rputs("</td><td><b>L</b>", r);
-                                break;
-                            case SERVER_BUSY_DNS:
-                                ap_rputs("</td><td><b>D</b>", r);
-                                break;
-                            case SERVER_CLOSING:
-                                ap_rputs("</td><td><b>C</b>", r);
-                                break;
-                            case SERVER_DEAD:
-                                ap_rputs("</td><td>.", r);
-                                break;
-                            case SERVER_GRACEFUL:
-                                ap_rputs("</td><td>G", r);
-                                break;
-                            case SERVER_IDLE_KILL:
-                                ap_rputs("</td><td>I", r);
-                                break;
-                            default:
-                                ap_rputs("</td><td>?", r);
-                                break;
-                            }
-
+                        
 #ifndef HAVE_TIMES
-                            /* Allow for OS/2 not having CPU stats */
-                            ap_rprintf(r, "\n</td><td>%.0f</td><td>%ld",
+                        /* Allow for OS/2 not having CPU stats */
+                        ap_rprintf(r, "\n</td><td>%.0f</td><td>%ld",
 #else
-                            ap_rprintf(r, "\n</td><td>%.2f</td><td>%ld</td><td>%ld",
-                                       (ws_record.times.tms_utime +
-                                        ws_record.times.tms_stime +
-                                        ws_record.times.tms_cutime +
-                                        ws_record.times.tms_cstime) / tick,
+                        ap_rprintf(r, "\n</td><td>%.2f</td><td>%ld</td><td>%ld",
+                                   (ws_record.times.tms_utime +
+                                    ws_record.times.tms_stime +
+                                    ws_record.times.tms_cutime +
+                                    ws_record.times.tms_cstime) / tick,
 #endif
-                                        (long)((nowtime - ws_record.last_used) /
-                                               APR_USEC_PER_SEC),
-                                        (long)req_time);
-
-                            ap_rprintf(r, "</td><td>%-1.1f</td><td>%-2.2f</td><td>%-2.2f\n",
-                                       (float)conn_bytes / KBYTE, (float) my_bytes / MBYTE,
-                                       (float)bytes / MBYTE);
-
-                            if (ws_record.status == SERVER_BUSY_READ)
-                                ap_rprintf(r,
-                                           "</td><td>?</td><td nowrap>?</td><td nowrap>..reading.. </td></tr>\n\n");
-                            else
-                                ap_rprintf(r,
-                                           "</td><td>%s</td><td nowrap>%s</td><td nowrap>%s</td></tr>\n\n",
-                                           ap_escape_html(r->pool,
-                                                          ws_record.client),
-                                           ap_escape_html(r->pool,
-                                                          ws_record.vhost),
-                                           ap_escape_html(r->pool,
-                                                          ws_record.request));
-                        } /* no_table_report */
-                    } /* !short_report */
-                } /* if (<active child>) */
-            } /* for () */
-        }
+                                   (long)((nowtime - ws_record.last_used) /
+                                          APR_USEC_PER_SEC),
+                                   (long)req_time);
+
+                        ap_rprintf(r, "</td><td>%-1.1f</td><td>%-2.2f</td><td>%-2.2f\n",
+                                   (float)conn_bytes / KBYTE, (float) my_bytes / MBYTE,
+                                   (float)bytes / MBYTE);
+
+                        if (ws_record.status == SERVER_BUSY_READ)
+                            ap_rprintf(r,
+                                       "</td><td>?</td><td nowrap>?</td><td nowrap>..reading.. </td></tr>\n\n");
+                        else
+                            ap_rprintf(r,
+                                       "</td><td>%s</td><td nowrap>%s</td><td nowrap>%s</td></tr>\n\n",
+                                       ap_escape_html(r->pool,
+                                                      ws_record.client),
+                                       ap_escape_html(r->pool,
+                                                      ws_record.vhost),
+                                       ap_escape_html(r->pool,
+                                                      ws_record.request));
+                    } /* no_table_report */
+                } /* !short_report */
+            } /* for (j...) */
+        } /* for (i...) */
 
         if (!(short_report || no_table_report)) {
 #ifndef HAVE_TIMES