Return-Path: Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: (qmail 14258 invoked from network); 24 Mar 2004 20:28:52 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 24 Mar 2004 20:28:52 -0000 Received: (qmail 66761 invoked by uid 500); 24 Mar 2004 20:28:43 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 66720 invoked by uid 500); 24 Mar 2004 20:28:43 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 66702 invoked by uid 500); 24 Mar 2004 20:28:43 -0000 Delivered-To: apmail-httpd-2.0-cvs@apache.org Received: (qmail 66695 invoked from network); 24 Mar 2004 20:28:43 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 24 Mar 2004 20:28:43 -0000 Received: (qmail 14227 invoked by uid 1462); 24 Mar 2004 20:28:49 -0000 Date: 24 Mar 2004 20:28:49 -0000 Message-ID: <20040324202849.14225.qmail@minotaur.apache.org> From: geoff@apache.org To: httpd-2.0-cvs@apache.org Subject: cvs commit: httpd-2.0/server/mpm/winnt child.c X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N geoff 2004/03/24 12:28:49 Modified: . Tag: APACHE_2_0_BRANCH CHANGES server/mpm/winnt Tag: APACHE_2_0_BRANCH child.c Log: Tweak worker thread accounting routines to eliminate server hang when number of Listen directives in httpd.conf is greater than or equal to the setting of ThreadsPerChild. Reviewed by: stoddard, trawick, geoff Revision Changes Path No revision No revision 1.988.2.258 +5 -0 httpd-2.0/CHANGES Index: CHANGES =================================================================== RCS file: /home/cvs/httpd-2.0/CHANGES,v retrieving revision 1.988.2.257 retrieving revision 1.988.2.258 diff -u -r1.988.2.257 -r1.988.2.258 --- CHANGES 18 Mar 2004 08:50:44 -0000 1.988.2.257 +++ CHANGES 24 Mar 2004 20:28:48 -0000 1.988.2.258 @@ -2,6 +2,11 @@ Changes with Apache 2.0.49 + *) Win32: Tweak worker thread accounting routines to eliminate + server hang when number of Listen directives in httpd.conf + is greater than or equal to the setting of ThreadsPerChild. + [Bill Stoddard] + *) SECURITY: CAN-2004-0174 (cve.mitre.org) Fix starvation issue on listening sockets where a short-lived connection on a rarely-accessed listening socket will cause a No revision No revision 1.9.2.15 +21 -4 httpd-2.0/server/mpm/winnt/child.c Index: child.c =================================================================== RCS file: /home/cvs/httpd-2.0/server/mpm/winnt/child.c,v retrieving revision 1.9.2.14 retrieving revision 1.9.2.15 diff -u -r1.9.2.14 -r1.9.2.15 --- child.c 8 Mar 2004 23:33:03 -0000 1.9.2.14 +++ child.c 24 Mar 2004 20:28:49 -0000 1.9.2.15 @@ -63,6 +63,7 @@ static PCOMP_CONTEXT qhead = NULL; static PCOMP_CONTEXT qtail = NULL; static int num_completion_contexts = 0; +static int max_num_completion_contexts = 0; static HANDLE ThreadDispatchIOCP = NULL; static HANDLE qwait_event = NULL; @@ -111,11 +112,12 @@ apr_thread_mutex_unlock(qlock); if (!context) { - /* We failed to grab a context off the queue, consider allocating a - * new one out of the child pool. There may be up to ap_threads_per_child - * contexts in the system at once. + /* We failed to grab a context off the queue, consider allocating + * a new one out of the child pool. There may be up to + * (ap_threads_per_child + num_listeners) contexts in the system + * at once. */ - if (num_completion_contexts >= ap_threads_per_child) { + if (num_completion_contexts >= max_num_completion_contexts) { /* All workers are busy, need to wait for one */ static int reported = 0; if (!reported) { @@ -766,6 +768,7 @@ static void create_listener_thread() { int tid; + int num_listeners = 0; if (!use_acceptex) { _beginthreadex(NULL, 0, (LPTHREAD_START_ROUTINE) win9x_accept, NULL, 0, &tid); @@ -774,6 +777,20 @@ * XXX: Why would we have a NULL sd in our listeners? */ ap_listen_rec *lr; + + /* Number of completion_contexts allowed in the system is + * (ap_threads_per_child + num_listeners). We need the additional + * completion contexts to prevent server hangs when ThreadsPerChild + * is configured to something less than or equal to the number + * of listeners. This is not a usual case, but people have + * encountered it. + * */ + for (lr = ap_listeners; lr ; lr = lr->next) { + num_listeners++; + } + max_num_completion_contexts = ap_threads_per_child + num_listeners; + + /* Now start a thread per listener */ for (lr = ap_listeners; lr; lr = lr->next) { if (lr->sd != NULL) { _beginthreadex(NULL, 1000, (LPTHREAD_START_ROUTINE) winnt_accept,