Commit 800dadd0 authored by Jim Jagielski's avatar Jim Jagielski
Browse files

Backport of pid table code from trunk & 2.2 to the 2.0 tree.

Create dev branch for this before we fold in


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/httpd-2.0-pid-table@547059 13f79535-47bb-0310-9956-ffa450edef68
parent a17238bd
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -260,6 +260,14 @@ const char *ap_mpm_set_scoreboard(cmd_parms *cmd, void *dummy,
                                  const char *arg);
#endif

/*
 * The parent process pid table
 */
extern apr_table_t *ap_pid_table;
int ap_in_pid_table(pid_t pid);
void ap_set_pid_table(pid_t pid);
void ap_unset_pid_table(pid_t pid); 

/*
 * The directory that the server changes directory to dump core.
 */
+1 −0
Original line number Diff line number Diff line
@@ -404,6 +404,7 @@ int main(int argc, const char * const argv[])
    ap_server_pre_read_config  = apr_array_make(pcommands, 1, sizeof(char *));
    ap_server_post_read_config = apr_array_make(pcommands, 1, sizeof(char *));
    ap_server_config_defines   = apr_array_make(pcommands, 1, sizeof(char *));
    ap_pid_table               = apr_table_make(pglobal, 1024);

    ap_setup_prelinked_modules(process);

+4 −1
Original line number Diff line number Diff line
@@ -22,7 +22,10 @@

#define MPM_NAME "Beos"
#define MPM_CHILD_PID(i) (ap_scoreboard_image->servers[0][i].tid)
#define MPM_NOTE_CHILD_KILLED(i) (MPM_CHILD_PID(i) = 0)
#define MPM_NOTE_CHILD_KILLED(i) do {         \
        ap_unset_pid_table(MPM_CHILD_PID(i)); \
        MPM_CHILD_PID(i) = 0;                 \
    } while(0) 

#define AP_MPM_WANT_RECLAIM_CHILD_PROCESSES
#define AP_MPM_WANT_WAIT_OR_TIMEOUT
+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include "httpd.h"
#include "mpm_default.h"
#include "scoreboard.h"
#include "mpm_common.h"

#define MPM_NAME "MPMT_OS2"

+10 −1
Original line number Diff line number Diff line
@@ -281,6 +281,7 @@ static char master_main()
#endif
    if (one_process) {
        ap_scoreboard_image->parent[0].pid = getpid();
        ap_set_pid_table(getpid());
        ap_mpm_child_main(pconf);
        return FALSE;
    }
@@ -307,6 +308,7 @@ static char master_main()
        rc = DosWaitChild(DCWA_PROCESSTREE, DCWW_NOWAIT, &proc_rc, &child_pid, 0);

        if (rc == 0) {
            ap_unset_pid_table(child_pid);
            /* A child has terminated, remove its scoreboard entry & terminate if necessary */
            for (slot=0; ap_scoreboard_image->parent[slot].pid != child_pid && slot < HARD_SERVER_LIMIT; slot++);

@@ -330,7 +332,13 @@ static char master_main()

    /* Signal children to shut down, either gracefully or immediately */
    for (slot=0; slot<HARD_SERVER_LIMIT; slot++) {
      kill(ap_scoreboard_image->parent[slot].pid, is_graceful ? SIGHUP : SIGTERM);
        PID pid;

        pid = ap_scoreboard_image->parent[n].pid;
        if (ap_in_pid_table(pid)) {
            kill(pid, is_graceful ? SIGHUP : SIGTERM);
            ap_unset_pid_table(pid);
        }
    }

    DosFreeMem(parent_info);
@@ -364,6 +372,7 @@ static void spawn_child(int slot)
    }

    ap_scoreboard_image->parent[slot].pid = proc_rc.codeTerminate;
    ap_set_pid_table(proc_rc.codeTerminate);
}


Loading