Commit 2750b11e authored by Tom Lane's avatar Tom Lane

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

deadlock on Win32.  Magnus Hagander
parent a1f7fb09
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* *
* IDENTIFICATION * 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) ...@@ -233,7 +233,7 @@ semop(int semId, struct sembuf * sops, int nsops)
wh[0] = cur_handle; wh[0] = cur_handle;
wh[1] = pgwin32_signal_event; 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) if (ret == WAIT_OBJECT_0)
{ {
...@@ -241,7 +241,7 @@ semop(int semId, struct sembuf * sops, int nsops) ...@@ -241,7 +241,7 @@ semop(int semId, struct sembuf * sops, int nsops)
sem_counts[sops[0].sem_num]--; sem_counts[sops[0].sem_num]--;
return 0; 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 */ /* Signal event is set - we have a signal to deliver */
pgwin32_dispatch_queued_signals(); pgwin32_dispatch_queued_signals();
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* *
* IDENTIFICATION * 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) ...@@ -93,7 +93,7 @@ TranslateSocketError(void)
static int static int
pgwin32_poll_signals(void) 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(); pgwin32_dispatch_queued_signals();
errno = EINTR; errno = EINTR;
...@@ -130,9 +130,9 @@ pgwin32_waitforsinglesocket(SOCKET s, int what) ...@@ -130,9 +130,9 @@ pgwin32_waitforsinglesocket(SOCKET s, int what)
events[0] = pgwin32_signal_event; events[0] = pgwin32_signal_event;
events[1] = waitevent; 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(); pgwin32_dispatch_queued_signals();
errno = EINTR; errno = EINTR;
...@@ -419,8 +419,8 @@ pgwin32_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, c ...@@ -419,8 +419,8 @@ pgwin32_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, c
} }
events[numevents] = pgwin32_signal_event; events[numevents] = pgwin32_signal_event;
r = WaitForMultipleObjectsEx(numevents + 1, events, FALSE, timeoutval, FALSE); r = WaitForMultipleObjectsEx(numevents + 1, events, FALSE, timeoutval, TRUE);
if (r != WSA_WAIT_TIMEOUT && r != (WAIT_OBJECT_0 + numevents)) 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 * We scan all events, even those not signalled, in case more than
......
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