httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stodd...@apache.org
Subject cvs commit: httpd-2.0/server/mpm/winnt child.c
Date Wed, 10 Mar 2004 15:05:52 GMT
stoddard    2004/03/10 07:05:52

  Modified:    .        CHANGES
               server/mpm/winnt child.c
  Log:
  Win32: Tweak worker thread accounting to fix hang when number of Listen directives is >=
ThreadsPerChild
  
  Revision  Changes    Path
  1.1420    +4 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.1419
  retrieving revision 1.1420
  diff -u -r1.1419 -r1.1420
  --- CHANGES	9 Mar 2004 17:58:46 -0000	1.1419
  +++ CHANGES	10 Mar 2004 15:05:51 -0000	1.1420
  @@ -1,6 +1,10 @@
   Changes with Apache 2.1.0-dev
   
     [Remove entries to the current 2.0 section below, when backported]
  +  *) 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]
   
     *) mod_rewrite: Support for recognizing SSL variables in RewriteCond
        using the new "SSL:" format.  [Joe Orton, Madhusudan Mathihalli]
  
  
  
  1.33      +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.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- child.c	1 Mar 2004 15:55:54 -0000	1.32
  +++ child.c	10 Mar 2004 15:05:52 -0000	1.33
  @@ -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) {
  @@ -811,6 +813,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);
  @@ -819,6 +822,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,
  
  
  

Mime
View raw message