Commit 23922a2f by Pascal Obry Committed by Arnaud Charlet

adaint.c: Fix possible race condition on win32_wait().

2008-08-22  Pascal Obry  <obry@adacore.com>

	* adaint.c: Fix possible race condition on win32_wait().

From-SVN: r139466
parent fb34edfa
...@@ -2266,6 +2266,7 @@ win32_wait (int *status) ...@@ -2266,6 +2266,7 @@ win32_wait (int *status)
DWORD res; DWORD res;
int k; int k;
Process_List *pl; Process_List *pl;
int hl_len;
if (plist_length == 0) if (plist_length == 0)
{ {
...@@ -2273,12 +2274,14 @@ win32_wait (int *status) ...@@ -2273,12 +2274,14 @@ win32_wait (int *status)
return -1; return -1;
} }
hl = (HANDLE *) xmalloc (sizeof (HANDLE) * plist_length);
k = 0; k = 0;
plist_enter(); plist_enter();
hl_len = plist_length;
/* -------------------- critical section -------------------- */ /* -------------------- critical section -------------------- */
hl = (HANDLE *) xmalloc (sizeof (HANDLE) * hl_len);
pl = PLIST; pl = PLIST;
while (pl) while (pl)
{ {
...@@ -2289,7 +2292,7 @@ win32_wait (int *status) ...@@ -2289,7 +2292,7 @@ win32_wait (int *status)
plist_leave(); plist_leave();
res = WaitForMultipleObjects (plist_length, hl, FALSE, INFINITE); res = WaitForMultipleObjects (hl_len, hl, FALSE, INFINITE);
h = hl[res - WAIT_OBJECT_0]; h = hl[res - WAIT_OBJECT_0];
free (hl); free (hl);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment