Changes with Apache 2.0.27-dev
+
+ *) Fix the reporting for child processes that die. This removes
+ all of the non-portable W* macros from Apache.
+ [Jeff Trawick and Ryan Bloom]
+
*) Win32: Track and display "Parent Server Generation:" in
mod_status output. The generation will be bumped at
server graceful restart, when the child process exits
* @param p The pool to allocate out of
*/
#ifdef AP_MPM_WANT_WAIT_OR_TIMEOUT
-void ap_wait_or_timeout(apr_wait_t *status, apr_proc_t *ret, apr_pool_t *p);
+void ap_wait_or_timeout(apr_exit_why_e *status, int *exitcode, apr_proc_t *ret,
+ apr_pool_t *p);
#endif
/**
* @param status The status returned from ap_wait_or_timeout
*/
#ifdef AP_MPM_WANT_PROCESS_CHILD_STATUS
-void ap_process_child_status(apr_proc_t *pid, apr_wait_t status);
+void ap_process_child_status(apr_proc_t *pid, apr_exit_why_e why, int status);
#endif
#if defined(TCP_NODELAY) && !defined(MPE) && !defined(TPF)
static void server_main_loop(int remaining_threads_to_start)
{
int child_slot;
- apr_wait_t status;
+ apr_exit_why_e exitwhy;
+ int status;
apr_proc_t pid;
int i;
while (!restart_pending && !shutdown_pending) {
- ap_wait_or_timeout(&status, &pid, pconf);
+ ap_wait_or_timeout(&exitwhy, &status, &pid, pconf);
if (pid.pid >= 0) {
- ap_process_child_status(&pid, status);
+ ap_process_child_status(&pid, exitwhy, status);
/* non-fatal death... note that it's gone in the scoreboard. */
child_slot = -1;
for (i = 0; i < ap_max_child_assigned; ++i) {
static void server_main_loop(int remaining_children_to_start)
{
int child_slot;
- apr_wait_t status;
+ apr_exit_why exitwhy;
+ int status;
apr_proc_t pid;
int i;
while (!restart_pending && !shutdown_pending) {
- ap_wait_or_timeout(&status, &pid, pconf);
+ ap_wait_or_timeout(&exitwhy, &status, &pid, pconf);
if (pid.pid != -1) {
- ap_process_child_status(&pid, status);
+ ap_process_child_status(&pid, exitwhy, status);
/* non-fatal death... note that it's gone in the child table and
* clean out the status table. */
child_slot = -1;
static void server_main_loop(int remaining_children_to_start)
{
int child_slot;
- apr_wait_t status;
+ apr_exit_why exitwhy;
+ int status;
apr_proc_t pid;
int i;
while (!restart_pending && !shutdown_pending) {
- ap_wait_or_timeout(&status, &pid, pconf);
+ ap_wait_or_timeout(&exitwhy, &status, &pid, pconf);
if (pid.pid != -1) {
- ap_process_child_status(&pid, status);
+ ap_process_child_status(&pid, exitwhy, status);
/* non-fatal death... note that it's gone in the child table and
* clean out the status table. */
child_slot = -1;
Systems without a real waitpid sometimes lose a child's exit while waiting
for another. Search through the scoreboard for missing children.
*/
-int reap_children(apr_wait_t *status)
+int reap_children(int *exitcode, apr_exit_why_e *status)
{
int n, pid;
kill((pid = ap_scoreboard_image->parent[n].pid), 0) == -1) {
ap_update_child_status(AP_CHILD_THREAD_FROM_ID(n), SERVER_DEAD, NULL);
/* just mark it as having a successful exit status */
- memset(status, 0, sizeof(apr_wait_t));
+ *status = APR_PROC_EXIT;
+ *exitcode = 0;
return(pid);
}
}
while (!restart_pending && !shutdown_pending) {
int child_slot;
- apr_wait_t status;
+ apr_exit_why_e exitwhy;
+ int status;
/* this is a memory leak, but I'll fix it later. */
apr_proc_t pid;
- ap_wait_or_timeout(&status, &pid, pconf);
+ ap_wait_or_timeout(&exitwhy, &status, &pid, 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.pid != -1) {
- ap_process_child_status(&pid, status);
+ ap_process_child_status(&pid, exitwhy, status);
/* non-fatal death... note that it's gone in the scoreboard. */
ap_sync_scoreboard_image();
child_slot = find_child_by_pid(&pid);
static void server_main_loop(int remaining_children_to_start)
{
int child_slot;
- apr_wait_t status;
+ apr_exit_why_e exitwhy;
+ int status;
apr_proc_t pid;
int i;
while (!restart_pending && !shutdown_pending) {
- ap_wait_or_timeout(&status, &pid, pconf);
+ ap_wait_or_timeout(&exitwhy, &status, &pid, pconf);
if (pid.pid != -1) {
- ap_process_child_status(&pid, status);
+ ap_process_child_status(&pid, exitwhy, status);
/* non-fatal death... note that it's gone in the scoreboard. */
child_slot = find_child_by_pid(&pid);
if (child_slot >= 0) {
static void server_main_loop(int remaining_children_to_start)
{
int child_slot;
- apr_wait_t status;
+ apr_exit_why_e exitwhy;
+ int status;
apr_proc_t pid;
int i;
while (!restart_pending && !shutdown_pending) {
- ap_wait_or_timeout(&status, &pid, pconf);
+ ap_wait_or_timeout(&exitwhy, &status, &pid, pconf);
if (pid.pid != -1) {
- ap_process_child_status(&pid, status);
+ ap_process_child_status(&pid, exitwhy, status);
/* non-fatal death... note that it's gone in the scoreboard. */
child_slot = find_child_by_pid(&pid);
if (child_slot >= 0) {
continue;
proc.pid = pid;
- waitret = apr_proc_wait(&proc, NULL, APR_NOWAIT);
+ waitret = apr_proc_wait(&proc, NULL, NULL, APR_NOWAIT);
if (waitret != APR_CHILD_NOTDONE) {
MPM_NOTE_CHILD_KILLED(i);
continue;
#endif
static int wait_or_timeout_counter;
-void ap_wait_or_timeout(apr_wait_t *status, apr_proc_t *ret, apr_pool_t *p)
+void ap_wait_or_timeout(apr_exit_why_e *status, int *exitcode, apr_proc_t *ret,
+ apr_pool_t *p)
{
apr_status_t rv;
if (wait_or_timeout_counter == INTERVAL_OF_WRITABLE_PROBES) {
wait_or_timeout_counter = 0;
}
- rv = apr_proc_wait_all_procs(ret, status, APR_NOWAIT, p);
+ rv = apr_proc_wait_all_procs(ret, exitcode, status, APR_NOWAIT, p);
if (APR_STATUS_IS_EINTR(rv)) {
ret->pid = -1;
return;
return;
}
#ifdef NEED_WAITPID
- if ((ret = reap_children(status)) > 0) {
+ if ((ret = reap_children(exitcode, status)) > 0) {
return;
}
#endif
#endif /* AP_MPM_WANT_WAIT_OR_TIMEOUT */
#ifdef AP_MPM_WANT_PROCESS_CHILD_STATUS
-void ap_process_child_status(apr_proc_t *pid, apr_wait_t status)
+void ap_process_child_status(apr_proc_t *pid, apr_exit_why_e why, int status)
{
- int signum = WTERMSIG(status);
+ int signum = status;
const char *sigdesc = apr_signal_get_description(signum);
/* Child died... if it died due to a fatal error,
* we should simply bail out.
*/
- if ((WIFEXITED(status)) &&
- WEXITSTATUS(status) == APEXIT_CHILDFATAL) {
+ if ((APR_PROC_CHECK_EXIT(why)) &&
+ (status == APEXIT_CHILDFATAL)) {
ap_log_error(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO, 0, ap_server_conf,
"Child %ld returned a Fatal error..." APR_EOL_STR
"Apache is exiting!",
exit(APEXIT_CHILDFATAL);
}
- if (WIFSIGNALED(status)) {
+ if (APR_PROC_CHECK_SIGNALED(why)) {
switch (signum) {
case SIGTERM:
case SIGHUP:
case SIGKILL:
break;
default:
-#ifdef WCOREDUMP
- if (WCOREDUMP(status)) {
+ if (APR_PROC_CHECK_CORE_DUMP(why)) {
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE,
0, ap_server_conf,
"child pid %ld exit signal %s (%d), "
(long)pid->pid, sigdesc, signum,
ap_coredump_dir);
}
- else
-#endif
- {
+ else {
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE,
0, ap_server_conf,
"child pid %ld exit signal %s (%d)",