This is a patch to worker.c to prevent more connections from being accepted than there are workers to handle them. The accept thread decrements the avail count and the workers increment the avail count.
I don't have a linux box handy so i cannot confirm this patch compiles. Sorry. Bill =================================================================== RCS file: /home/cvs/httpd-2.0/server/mpm/worker/worker.c,v retrieving revision 1.117 diff -u -r1.117 worker.c --- worker.c 18 Apr 2002 17:46:20 -0000 1.117 +++ worker.c 26 Apr 2002 17:59:16 -0000 @@ -156,6 +156,7 @@ */ int ap_threads_per_child = 0; /* Worker threads per child */ +static int worker_thread_cnt = 0; static int ap_daemons_to_start = 0; static int min_spare_threads = 0; static int max_spare_threads = 0; @@ -693,6 +694,14 @@ } if (listener_may_exit) break; + /* If no worker threads are available, yield our quanta and try again + * later + */ + if (!worker_thread_cnt) { + yield(); + continue; + } + if ((rv = SAFE_ACCEPT(apr_proc_mutex_lock(accept_mutex))) != APR_SUCCESS) { int level = APLOG_EMERG; @@ -791,6 +800,7 @@ signal_threads(ST_GRACEFUL); } if (csd != NULL) { + worker_thread_cnt--; rv = ap_queue_push(worker_queue, csd, ptrans, &recycled_pool); if (rv) { @@ -852,6 +862,7 @@ while (!workers_may_exit) { ap_update_child_status_from_indexes(process_slot, thread_slot, SERVER_READY, NULL); + worker_thread_cnt++; rv = ap_queue_pop(worker_queue, &csd, &ptrans, last_ptrans); last_ptrans = NULL;