summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndres Freund2016-03-18 18:43:59 +0000
committerAndres Freund2016-03-18 18:46:45 +0000
commit6bc4d95fcc2a432fc202cba03d5393be096f0422 (patch)
tree1cb1ba00b741eba962d21a55bb304507f24dd110
parentfad0f9d8c9f6a8e99156b8f01cba54be39f31761 (diff)
Error out if waiting on socket readiness without a specified socket.
Previously we just ignored such an attempt, but that seems to serve no purpose but making things harder to debug. Discussion: [email protected] [email protected] Reviewed-By: Robert Haas
-rw-r--r--src/backend/port/unix_latch.c9
-rw-r--r--src/backend/port/win32_latch.c9
2 files changed, 10 insertions, 8 deletions
diff --git a/src/backend/port/unix_latch.c b/src/backend/port/unix_latch.c
index 2ad609c436e..9f8b8d54f07 100644
--- a/src/backend/port/unix_latch.c
+++ b/src/backend/port/unix_latch.c
@@ -226,12 +226,13 @@ WaitLatchOrSocket(volatile Latch *latch, int wakeEvents, pgsocket sock,
int hifd;
#endif
- /* Ignore WL_SOCKET_* events if no valid socket is given */
- if (sock == PGINVALID_SOCKET)
- wakeEvents &= ~(WL_SOCKET_READABLE | WL_SOCKET_WRITEABLE);
-
Assert(wakeEvents != 0); /* must have at least one wake event */
+ /* waiting for socket readiness without a socket indicates a bug */
+ if (sock == PGINVALID_SOCKET &&
+ (wakeEvents & (WL_SOCKET_READABLE | WL_SOCKET_WRITEABLE)) != 0)
+ elog(ERROR, "cannot wait on socket event without a socket");
+
if ((wakeEvents & WL_LATCH_SET) && latch->owner_pid != MyProcPid)
elog(ERROR, "cannot wait on a latch owned by another process");
diff --git a/src/backend/port/win32_latch.c b/src/backend/port/win32_latch.c
index 80adc13e68a..b1b071339ee 100644
--- a/src/backend/port/win32_latch.c
+++ b/src/backend/port/win32_latch.c
@@ -113,12 +113,13 @@ WaitLatchOrSocket(volatile Latch *latch, int wakeEvents, pgsocket sock,
int result = 0;
int pmdeath_eventno = 0;
- /* Ignore WL_SOCKET_* events if no valid socket is given */
- if (sock == PGINVALID_SOCKET)
- wakeEvents &= ~(WL_SOCKET_READABLE | WL_SOCKET_WRITEABLE);
-
Assert(wakeEvents != 0); /* must have at least one wake event */
+ /* waiting for socket readiness without a socket indicates a bug */
+ if (sock == PGINVALID_SOCKET &&
+ (wakeEvents & (WL_SOCKET_READABLE | WL_SOCKET_WRITEABLE)) != 0)
+ elog(ERROR, "cannot wait on socket event without a socket");
+
if ((wakeEvents & WL_LATCH_SET) && latch->owner_pid != MyProcPid)
elog(ERROR, "cannot wait on a latch owned by another process");