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 mpm_winnt.c
Date Thu, 22 Mar 2001 23:05:55 GMT
stoddard    01/03/22 15:05:55

  Modified:    .        CHANGES
               server/mpm/winnt mpm_winnt.c
  Log:
  Win32: Don't accept more connections that we have worker threads
  to handle. This is specific to NT/2000.
  
  Revision  Changes    Path
  1.143     +4 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.142
  retrieving revision 1.143
  diff -u -r1.142 -r1.143
  --- CHANGES	2001/03/22 19:29:05	1.142
  +++ CHANGES	2001/03/22 23:05:50	1.143
  @@ -1,4 +1,8 @@
   Changes with Apache 2.0.15-dev
  +  *) Win32: Don't accept more connections than we have worker threads
  +     to handle.
  +     [Bill Stoddard]
  +
     *) Fix bug in the Unix threaded.c MPM that allowed child processes
        to fork() new child processes. 
        [Bill Stoddard]
  
  
  
  1.150     +18 -6     httpd-2.0/server/mpm/winnt/mpm_winnt.c
  
  Index: mpm_winnt.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/winnt/mpm_winnt.c,v
  retrieving revision 1.149
  retrieving revision 1.150
  diff -u -r1.149 -r1.150
  --- mpm_winnt.c	2001/03/12 18:10:49	1.149
  +++ mpm_winnt.c	2001/03/22 23:05:54	1.150
  @@ -111,7 +111,7 @@
   apr_lock_t  *qlock;
   COMP_CONTEXT *qhead = NULL;
   COMP_CONTEXT *qtail = NULL;
  -static unsigned int g_num_completion_contexts = 0;
  +
   static HANDLE ThreadDispatchIOCP = NULL;
   
   /* Definitions of WINNT MPM specific config globals */
  @@ -670,6 +670,7 @@
    */
   static void winnt_accept(void *listen_socket) 
   {
  +    static int num_completion_contexts = 0;
       PCOMP_CONTEXT pCompContext;
       DWORD BytesRead;
       SOCKET nlsd;
  @@ -679,7 +680,7 @@
   
       while (1) {
           pCompContext = NULL;
  -        /* Grab a context off the queue if there is one available */
  +        /* Grab a context off the queue */
           apr_lock_acquire(qlock);
           if (qhead) {
               pCompContext = qhead;
  @@ -689,11 +690,22 @@
           }
           apr_lock_release(qlock);
   
  -        /* Alloc a new context out of the child pool if none were available on
  -         * the queue. Todo: Place a max upper limit on the number of completion
  -         * contexts in the system.
  +        /* If we failed to grab a context off the queue, alloc one out of 
  +         * the child pool. There may be up to ap_threads_per_child contexts
  +         * in the system at once.
            */
           if (!pCompContext) {
  +            if (num_completion_contexts >= ap_threads_per_child) {
  +                static int reported = 0;
  +                if (!reported) {
  +                    ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, server_conf,
  +                                 "Server ran out of threads to serve requests. Consider
"
  +                                 "raising the ThreadsPerChild setting");
  +                    reported = 1;
  +                }
  +                Sleep(500);
  +                continue;
  +            }
               pCompContext = (PCOMP_CONTEXT) apr_pcalloc(pchild, sizeof(COMP_CONTEXT));
   
               pCompContext->Overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);

  @@ -703,7 +715,7 @@
                   // return -1;
               }
               pCompContext->accept_socket = INVALID_SOCKET;
  -            g_num_completion_contexts++;
  +            num_completion_contexts++;
           }
   
       again:            
  
  
  

Mime
View raw message