stoddard    98/09/10 10:38:02

  Modified:    src/main http_main.c
  Log:
  Remove NT 64 thread limit.
  Submitted by: Ken Parzygnat, Bill Stoddard
  Reviewed by:  Bill Stoddard
  
  Revision  Changes    Path
  1.389     +43 -3     apache-1.3/src/main/http_main.c
  
  Index: http_main.c
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/main/http_main.c,v
  retrieving revision 1.388
  retrieving revision 1.389
  diff -u -r1.388 -r1.389
  --- http_main.c       1998/08/26 20:01:22     1.388
  +++ http_main.c       1998/09/10 17:38:00     1.389
  @@ -4919,7 +4919,46 @@
        handles[i] = handles[i + 1];
       (*thread_cnt)--;
   }
  -
  +#ifdef WIN32
  +/*
  + * The Win32 call WaitForMultipleObjects will only allow you to wait for 
  + * a maximum of MAXIMUM_WAIT_OBJECTS (current 64).  Since the threading 
  + * model in the multithreaded version of apache wants to use this call, 
  + * we are restricted to a maximum of 64 threads.  This is a simplistic 
  + * routine that will increase this size.
  + */
  +DWORD wait_for_many_objects(DWORD nCount, CONST HANDLE *lpHandles, 
  +                            DWORD dwSeconds)
  +{
  +    time_t tStopTime;
  +    DWORD dwRet = WAIT_TIMEOUT;
  +    DWORD dwIndex=0;
  +    BOOL bFirst = TRUE;
  +  
  +    tStopTime = time(NULL) + dwSeconds;
  +  
  +    do {
  +        if (!bFirst)
  +            Sleep(1000);
  +        else
  +            bFirst = FALSE;
  +          
  +        for (dwIndex = 0; dwIndex * MAXIMUM_WAIT_OBJECTS < nCount; 
dwIndex++) {
  +            dwRet = WaitForMultipleObjects(
  +                        min(MAXIMUM_WAIT_OBJECTS, 
  +                            nCount - (dwIndex * MAXIMUM_WAIT_OBJECTS)),
  +                        lpHandles + (dwIndex * MAXIMUM_WAIT_OBJECTS), 
  +                        0, 0);
  +                                           
  +            if (dwRet != WAIT_TIMEOUT) {                                     
     
  +              break;
  +            }
  +        }
  +    } while((time(NULL) < tStopTime) && (dwRet == WAIT_TIMEOUT));
  +    
  +    return dwRet;
  +}
  +#endif
   /*****************************************************************
    * Executive routines.
    */
  @@ -5074,7 +5113,7 @@
                /* Lets not break yet - we may have threads to clean up */
                /* break;*/
            }
  -         rv = WaitForMultipleObjects(nthreads, child_handles, 0, 0);
  +         rv = wait_for_many_objects(nthreads, child_handles, 0);
            ap_assert(rv != WAIT_FAILED);
            if (rv != WAIT_TIMEOUT) {
                rv = rv - WAIT_OBJECT_0;
  @@ -5185,7 +5224,8 @@
       /* Wait for all your children */
       end_time = time(NULL) + 180;
       while (nthreads) {
  -     rv = WaitForMultipleObjects(nthreads, child_handles, 0, (end_time - 
time(NULL)) * 1000);
  +        rv = wait_for_many_objects(nthreads, child_handles, 
  +                                   end_time - time(NULL));
        if (rv != WAIT_TIMEOUT) {
            rv = rv - WAIT_OBJECT_0;
            ap_assert((rv >= 0) && (rv < nthreads));
  
  
  

Reply via email to