#endif
void ap_reclaim_child_processes(int terminate);
-ap_proc_t *ap_wait_or_timeout(ap_wait_t *status, ap_pool_t *p);
+void ap_wait_or_timeout(ap_wait_t *status, ap_proc_t *ret, ap_pool_t *p);
#ifdef __cplusplus
}
{
int child_slot;
ap_wait_t status;
- ap_proc_t *pid;
+ ap_proc_t pid;
int i;
while (!restart_pending && !shutdown_pending) {
- pid = ap_wait_or_timeout(&status, pconf);
+ ap_wait_or_timeout(&status, &pid, pconf);
- if (pid != NULL) {
- process_child_status(pid, status);
+ if (pid.pid != -1) {
+ 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 < ap_max_daemons_limit; ++i) {
- if (ap_child_table[i].pid == pid->pid) {
+ if (ap_child_table[i].pid == pid.pid) {
int j;
child_slot = i;
}
#ifdef APR_HAS_OTHER_CHILD
}
- else if (ap_reap_other_child(pid, status) == 0) {
+ else if (ap_reap_other_child(&pid, status) == 0) {
/* handled */
#endif
}
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, errno,
ap_server_conf,
"long lost child came home! (pid %ld)",
- (long)pid->pid);
+ (long)pid.pid);
}
/* Don't perform idle maintenance when a child dies,
* only do it when there's a timeout. Remember only a
{
int child_slot;
ap_wait_t status;
- ap_proc_t *pid;
+ ap_proc_t pid;
int i;
while (!restart_pending && !shutdown_pending) {
- /* this is a memory leak, but I'll fix it later. */
- pid = ap_wait_or_timeout(&status, pconf);
+ ap_wait_or_timeout(&status, &pid, pconf);
- if (pid != NULL) {
- process_child_status(pid, status);
+ if (pid.pid != -1) {
+ process_child_status(&pid, status);
/* non-fatal death... note that it's gone in the scoreboard. */
- child_slot = find_child_by_pid(pid);
+ child_slot = find_child_by_pid(&pid);
if (child_slot >= 0) {
ap_mpmt_pthread_force_reset_connection_status(child_slot);
for (i = 0; i < ap_threads_per_child; i++)
}
#ifdef APR_HAS_OTHER_CHILD
}
- else if (ap_reap_other_child(pid, status) == 0) {
+ else if (ap_reap_other_child(&pid, status) == 0) {
/* handled */
#endif
}
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0,
ap_server_conf,
"long lost child came home! (pid %ld)",
- (long)pid->pid);
+ (long)pid.pid);
}
/* Don't perform idle maintenance when a child dies,
* only do it when there's a timeout. Remember only a
int child_slot;
ap_wait_t status;
/* this is a memory leak, but I'll fix it later. */
- ap_proc_t *pid = ap_wait_or_timeout(&status, pconf);
+ ap_proc_t pid;
+
+ ap_wait_or_timeout(&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 != NULL) {
- process_child_status(pid, status);
+ if (pid.pid != -1) {
+ process_child_status(&pid, status);
/* non-fatal death... note that it's gone in the scoreboard. */
ap_sync_scoreboard_image();
- child_slot = find_child_by_pid(pid);
+ child_slot = find_child_by_pid(&pid);
if (child_slot >= 0) {
ap_prefork_force_reset_connection_status(child_slot);
(void) ap_update_child_status(child_slot, SERVER_DEAD,
}
#ifdef APR_HAS_OTHER_CHILD
}
- else if (ap_reap_other_child(pid, status) == 0) {
+ else if (ap_reap_other_child(&pid, status) == 0) {
/* handled */
#endif
}
*/
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING,
0, ap_server_conf,
- "long lost child came home! (pid %d)", pid->pid);
+ "long lost child came home! (pid %d)", pid.pid);
}
/* Don't perform idle maintenance when a child dies,
* only do it when there's a timeout. Remember only a
#endif
static int wait_or_timeout_counter;
-ap_proc_t *ap_wait_or_timeout(ap_wait_t *status, ap_pool_t *p)
+void ap_wait_or_timeout(ap_wait_t *status, ap_proc_t *ret, ap_pool_t *p)
{
struct timeval tv;
ap_status_t rv;
- ap_proc_t *ret = ap_pcalloc(p, sizeof(*ret));
++wait_or_timeout_counter;
if (wait_or_timeout_counter == INTERVAL_OF_WRITABLE_PROBES) {
}
rv = ap_wait_all_procs(ret, status, APR_NOWAIT, p);
if (ap_canonical_error(rv) == APR_EINTR) {
- return NULL;
+ ret->pid = -1;
+ return;
}
if (rv == APR_CHILD_DONE) {
- return ret;
+ return;
}
#ifdef NEED_WAITPID
if ((ret = reap_children(status)) > 0) {
- return ret;
+ return;
}
#endif
tv.tv_sec = SCOREBOARD_MAINTENANCE_INTERVAL / 1000000;
tv.tv_usec = SCOREBOARD_MAINTENANCE_INTERVAL % 1000000;
ap_select(0, NULL, NULL, NULL, &tv);
- return NULL;
+ ret->pid = -1;
+ return;
}