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
This commit is contained in:
Pascal Obry 2008-08-22 15:26:38 +02:00 committed by Arnaud Charlet
parent fb34edfafa
commit 23922a2f6a
1 changed files with 6 additions and 3 deletions

View File

@ -2266,6 +2266,7 @@ win32_wait (int *status)
DWORD res;
int k;
Process_List *pl;
int hl_len;
if (plist_length == 0)
{
@ -2273,12 +2274,14 @@ win32_wait (int *status)
return -1;
}
hl = (HANDLE *) xmalloc (sizeof (HANDLE) * plist_length);
k = 0;
plist_enter();
hl_len = plist_length;
/* -------------------- critical section -------------------- */
hl = (HANDLE *) xmalloc (sizeof (HANDLE) * hl_len);
pl = PLIST;
while (pl)
{
@ -2289,7 +2292,7 @@ win32_wait (int *status)
plist_leave();
res = WaitForMultipleObjects (plist_length, hl, FALSE, INFINITE);
res = WaitForMultipleObjects (hl_len, hl, FALSE, INFINITE);
h = hl[res - WAIT_OBJECT_0];
free (hl);