]> granicus.if.org Git - apache/commitdiff
Fix return values from wait_for_many_objects.
authorMladen Turk <mturk@apache.org>
Wed, 2 Aug 2006 15:31:24 +0000 (15:31 +0000)
committerMladen Turk <mturk@apache.org>
Wed, 2 Aug 2006 15:31:24 +0000 (15:31 +0000)
The return value is index to the signaled thread in
the creted_threads array.
We can not use WAIT_TIMEOUT as return value
because its value is defined as 258, thus limiting
the MaxThreads to that value that leads to the
assertion errors.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@428029 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
os/win32/util_win32.c
server/mpm/winnt/child.c

diff --git a/CHANGES b/CHANGES
index 5f5da5276f8f25ff598e26b5a7ac70fa5e8f02e7..1e0ed285528905a558a6e48835a0b209a8ca39b4 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,12 @@
 Changes with Apache 2.3.0
   [Remove entries to the current 2.0 and 2.2 section below, when backported]
 
+  *) mpm_winnt: Fix return values from wait_for_many_objects.
+     The return value is index to the signaled thread in the
+     creted_threads array. We can not use WAIT_TIMEOUT because
+     his value is defined as 258, thus limiting the MaxThreads
+     to that value. [Mladen Turk]
+
   *) mod_proxy_balancer: Workers can now be defined as part of
      a balancer cluster "set" in which members of a lower-numbered set
      are preferred over higher numbered ones. [Jim Jagielski]
index a0bb7fd7de14d61fa7126d246f93ee936d804923..e8ba49c760ea98d6e15db81511262f6387ed4353 100644 (file)
@@ -158,7 +158,7 @@ DWORD wait_for_many_objects(DWORD nCount, CONST HANDLE *lpHandles,
                             DWORD dwSeconds)
 {
     time_t tStopTime;
-    DWORD dwRet = WAIT_TIMEOUT;
+    DWORD dwRet = WAIT_FAILED;
     DWORD dwIndex=0;
     BOOL bFirst = TRUE;
 
@@ -175,12 +175,20 @@ DWORD wait_for_many_objects(DWORD nCount, CONST HANDLE *lpHandles,
                 min(MAXIMUM_WAIT_OBJECTS, nCount - (dwIndex * MAXIMUM_WAIT_OBJECTS)),
                 lpHandles + (dwIndex * MAXIMUM_WAIT_OBJECTS),
                 0, 0);
-
+            if (dwRet == WAIT_FAILED) {
+                return dwRet;
+            }
             if (dwRet != WAIT_TIMEOUT) {
-              break;
+                if (dwRet >= WAIT_ABANDONED_0)
+                    dwRet = dwRet - WAIT_ABANDONED_0;
+                else
+                    dwRet = dwRet - WAIT_OBJECT_0;
+                dwRet = dwRet + (dwIndex * MAXIMUM_WAIT_OBJECTS);
+                break;
             }
+            dwRet = WAIT_FAILED;
         }
-    } while((time(NULL) < tStopTime) && (dwRet == WAIT_TIMEOUT));
+    } while((time(NULL) < tStopTime) && (dwRet == WAIT_FAILED));
 
     return dwRet;
 }
index d950869806ab4e3f53096bbf6f78e9b52fa852c8..4d83252157009be42232f619748eb5c74150cd9e 100644 (file)
@@ -1119,8 +1119,7 @@ void child_main(apr_pool_t *pconf)
     end_time = time(NULL) + 180;
     while (threads_created) {
         rv = wait_for_many_objects(threads_created, child_handles, (DWORD)(end_time - time(NULL)));
-        if (rv != WAIT_TIMEOUT) {
-            rv = rv - WAIT_OBJECT_0;
+        if (rv != WAIT_FAILED) {
             ap_assert((rv >= 0) && (rv < threads_created));
             cleanup_thread(child_handles, &threads_created, rv);
             continue;