Fix places where WaitForxxx can block, to eliminate failure to detect

deadlock on Win32.  Magnus Hagander
This commit is contained in:
Tom Lane 2004-09-07 14:31:42 +00:00
parent a1f7fb0975
commit 2750b11e18
2 changed files with 9 additions and 9 deletions

View File

@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/port/win32/sema.c,v 1.8 2004/08/29 05:06:46 momjian Exp $
* $PostgreSQL: pgsql/src/backend/port/win32/sema.c,v 1.9 2004/09/07 14:31:42 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -233,7 +233,7 @@ semop(int semId, struct sembuf * sops, int nsops)
wh[0] = cur_handle;
wh[1] = pgwin32_signal_event;
ret = WaitForMultipleObjects(2, wh, FALSE, (sops[0].sem_flg & IPC_NOWAIT) ? 0 : INFINITE);
ret = WaitForMultipleObjectsEx(2, wh, FALSE, (sops[0].sem_flg & IPC_NOWAIT) ? 0 : INFINITE, TRUE);
if (ret == WAIT_OBJECT_0)
{
@ -241,7 +241,7 @@ semop(int semId, struct sembuf * sops, int nsops)
sem_counts[sops[0].sem_num]--;
return 0;
}
else if (ret == WAIT_OBJECT_0 + 1)
else if (ret == WAIT_OBJECT_0 + 1 || ret == WAIT_IO_COMPLETION)
{
/* Signal event is set - we have a signal to deliver */
pgwin32_dispatch_queued_signals();

View File

@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/port/win32/socket.c,v 1.5 2004/08/30 02:54:38 momjian Exp $
* $PostgreSQL: pgsql/src/backend/port/win32/socket.c,v 1.6 2004/09/07 14:31:42 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -93,7 +93,7 @@ TranslateSocketError(void)
static int
pgwin32_poll_signals(void)
{
if (WaitForSingleObject(pgwin32_signal_event, 0) == WAIT_OBJECT_0)
if (WaitForSingleObjectEx(pgwin32_signal_event, 0, TRUE) == WAIT_OBJECT_0)
{
pgwin32_dispatch_queued_signals();
errno = EINTR;
@ -130,9 +130,9 @@ pgwin32_waitforsinglesocket(SOCKET s, int what)
events[0] = pgwin32_signal_event;
events[1] = waitevent;
r = WaitForMultipleObjects(2, events, FALSE, INFINITE);
r = WaitForMultipleObjectsEx(2, events, FALSE, INFINITE, TRUE);
if (r == WAIT_OBJECT_0)
if (r == WAIT_OBJECT_0 || r == WAIT_IO_COMPLETION)
{
pgwin32_dispatch_queued_signals();
errno = EINTR;
@ -419,8 +419,8 @@ pgwin32_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, c
}
events[numevents] = pgwin32_signal_event;
r = WaitForMultipleObjectsEx(numevents + 1, events, FALSE, timeoutval, FALSE);
if (r != WSA_WAIT_TIMEOUT && r != (WAIT_OBJECT_0 + numevents))
r = WaitForMultipleObjectsEx(numevents + 1, events, FALSE, timeoutval, TRUE);
if (r != WAIT_TIMEOUT && r != WAIT_IO_COMPLETION && r != (WAIT_OBJECT_0 + numevents))
{
/*
* We scan all events, even those not signalled, in case more than