Index: server/mpm/worker/worker.c =================================================================== RCS file: /m0xa/cvs/phoenix/2.0.47/server/mpm/worker/worker.c,v retrieving revision 1.14 diff -u -r1.14 worker.c --- server/mpm/worker/worker.c 19 Jan 2005 21:11:10 -0000 1.14 +++ server/mpm/worker/worker.c 23 Feb 2005 00:14:06 -0000 @@ -1024,14 +1024,7 @@ if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ALERT, rv, ap_server_conf, "apr_thread_create: unable to create listener thread"); - /* In case system resources are maxxed out, we don't want - * Apache running away with the CPU trying to fork over and - * over and over again if we exit. - * XXX Jeff doesn't see how Apache is going to try to fork again since - * the exit code is APEXIT_CHILDFATAL - */ - apr_sleep(apr_time_from_sec(10)); - clean_child_exit(APEXIT_CHILDFATAL); + clean_child_exit(APEXIT_CHILDSICK); } apr_os_thread_get(&listener_os_thread, ts->listener); } @@ -1105,14 +1098,19 @@ */ rv = apr_thread_create(&threads[i], thread_attr, worker_thread, my_info, pchild); +#if 0 + if (threads_created > 20) { + struct stat sb; + + if (stat("/tmp/FAIL", &sb) == 0) { + rv = EIO; + } + } +#endif if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ALERT, rv, ap_server_conf, "apr_thread_create: unable to create worker thread"); - /* In case system resources are maxxed out, we don't want - Apache running away with the CPU trying to fork over and - over and over again if we exit. */ - apr_sleep(apr_time_from_sec(10)); - clean_child_exit(APEXIT_CHILDFATAL); + clean_child_exit(APEXIT_CHILDSICK); } threads_created++; } @@ -1310,11 +1308,7 @@ if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ALERT, rv, ap_server_conf, "apr_thread_create: unable to create worker thread"); - /* In case system resources are maxxed out, we don't want - Apache running away with the CPU trying to fork over and - over and over again if we exit. */ - apr_sleep(apr_time_from_sec(10)); - clean_child_exit(APEXIT_CHILDFATAL); + clean_child_exit(APEXIT_CHILDSICK); } /* If we are only running in one_process mode, we will want to @@ -1658,8 +1652,20 @@ ap_scoreboard_image->parent[child_slot].pid = 0; ap_scoreboard_image->parent[child_slot].quiescing = 0; if (processed_status == APEXIT_CHILDSICK) { + int seconds = 4; /* resource shortage, minimize the fork rate */ idle_spawn_rate = 1; + /* sleep for a while to slow us down even more than + * minimizing the fork rate; note that this + * feedback is asynchronous and we may have multiple + * child processes reporting this at about the same time, + * so don't sleep as much time here as we do if we + * encounter a fork() failure + */ + ap_log_error(APLOG_MARK, APLOG_CRIT, 0, ap_server_conf, + "A child process encountered a resource shortage; pausing %d seconds.", + seconds); + apr_sleep(apr_time_from_sec(seconds)); } else if (remaining_children_to_start && child_slot < ap_daemons_limit) {