Commit 06c9b2af authored by Jeff Trawick's avatar Jeff Trawick
Browse files

worker MPM/mod_status: Support per-worker tracking of pid and

generation in the scoreboard so that mod_status can accurately
represent workers in processes which are gracefully terminating.

New child processes with worker MPM can take over slots of
individual threads within gracefully terminating processes.
Sometimes this is a problem (too many of these gracefully
terminating processes), so it is helpful to have mod_status
provide the information required to recognize these processes.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@156274 13f79535-47bb-0310-9956-ffa450edef68
parent dc06a7ab
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -2,6 +2,12 @@ Changes with Apache 2.1.4
  [Remove entries to the current 2.0 section below, when backported]
  *) worker MPM/mod_status: Support per-worker tracking of pid and
     generation in the scoreboard so that mod_status can accurately
     represent workers in processes which are gracefully terminating.
     (major MMN bump)
     [Jeff Trawick]
  *) Correctly export all mod_dav public functions.
     [Branko Èibej <brane xbc.nu>]
+1 −0
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@
 * 20050217.0 (2.1.3-dev) Axed find_child_by_pid, mpm_*_completion_context (winnt mpm)
 *                        symbols from the public sector, and decorated real_exit_code
 *                        with ap_ in the win32 os.h.
 * 20050305.0 (2.1.4-dev) added pid and generation fields to worker_score
 */

#define MODULE_MAGIC_COOKIE 0x41503230UL /* "AP20" */
+7 −0
Original line number Diff line number Diff line
@@ -99,6 +99,13 @@ struct worker_score {
#if APR_HAS_THREADS
    apr_os_thread_t tid;
#endif
    /* With some MPMs (e.g., worker), a worker_score can represent
     * a thread in a terminating process which is no longer
     * represented by the corresponding process_score.  These MPMs
     * should set pid and generation fields in the worker_score.
     */
    pid_t pid;
    ap_generation_t generation;
    unsigned char status;
    unsigned long access_count;
    apr_off_t     bytes_served;
+18 −8
Original line number Diff line number Diff line
@@ -229,8 +229,9 @@ static int status_handler(request_rec *r)
    worker_score *ws_record;
    process_score *ps_record;
    char *stat_buffer;
    pid_t *pid_buffer;
    pid_t *pid_buffer, worker_pid;
    clock_t tu, ts, tcu, tcs;
    ap_generation_t worker_generation;

    if (strcmp(r->handler, STATUS_MAGIC_TYPE) && 
        strcmp(r->handler, "server-status")) {
@@ -584,19 +585,27 @@ static int status_handler(request_rec *r)
                bytes = ws_record->bytes_served;
                my_bytes = ws_record->my_bytes_served;
                conn_bytes = ws_record->conn_bytes;
                if (ws_record->pid) { /* MPM sets per-worker pid and generation */
                    worker_pid = ws_record->pid;
                    worker_generation = ws_record->generation;
                }
                else {
                    worker_pid = ps_record->pid;
                    worker_generation = ps_record->generation;
                }
 
                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,
                                   i, (int)worker_generation,
                                   (int)conn_lres, my_lres, lres);
                    else
                        ap_rprintf(r,
                                   "<b>Server %d-%d</b> (%"
                                   APR_PID_T_FMT "): %d|%lu|%lu [",
                                   i, (int) ps_record->generation,
                                   ps_record->pid,
                                   i, (int) worker_generation,
                                   worker_pid,
                                   (int)conn_lres, my_lres, lres);
                    
                    switch (ws_record->status) {
@@ -672,15 +681,16 @@ static int status_handler(request_rec *r)
                    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,
                                   i, (int)worker_generation,
                                   (int)conn_lres, my_lres, lres);
                    else
                        ap_rprintf(r,
                                   "<tr><td><b>%d-%d</b></td><td>%"
                                   APR_PID_T_FMT
                                   "</td><td>%d/%lu/%lu",
                                   i, (int)ps_record->generation,
                                   ps_record->pid, (int)conn_lres,
                                   i, (int)worker_generation,
                                   worker_pid,
                                   (int)conn_lres,
                                   my_lres, lres);
                    
                    switch (ws_record->status) {
+2 −0
Original line number Diff line number Diff line
@@ -800,6 +800,8 @@ static void * APR_THREAD_FUNC worker_thread(apr_thread_t *thd, void * dummy)

    free(ti);

    ap_scoreboard_image->servers[process_slot][thread_slot].pid = ap_my_pid;
    ap_scoreboard_image->servers[process_slot][thread_slot].generation = ap_my_generation;
    ap_update_child_status_from_indexes(process_slot, thread_slot, SERVER_STARTING, NULL);

    while (!workers_may_exit) {