summaryrefslogtreecommitdiff
path: root/src/backend/port/win32_latch.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2012-05-14 16:11:59 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2012-05-14 16:12:28 -0400
commite42a21b9e6c9b9e6346a34b62628d48ff2fc6ddf (patch)
tree1d4c8483388c1ce744113596d457a4fd4f5cbe35 /src/backend/port/win32_latch.c
parentff4628f37a1e700d1fe716d0c271f68d8aa1e4ea (diff)
Assert that WaitLatchOrSocket callers cannot wait only for writability.
Since we have chosen to report socket EOF and error conditions via the WL_SOCKET_READABLE flag bit, it's unsafe to wait only for WL_SOCKET_WRITEABLE; the caller would never be notified of the socket condition, and in some of these implementations WaitLatchOrSocket would busy-wait until something else happens. Add this restriction to the API specification, and add Asserts to check that callers don't try to do that. At some point we might want to consider adjusting the API to relax this restriction, but until we have an actual use case for waiting on a write-only socket, it seems premature to design a solution.
Diffstat (limited to 'src/backend/port/win32_latch.c')
-rw-r--r--src/backend/port/win32_latch.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/backend/port/win32_latch.c b/src/backend/port/win32_latch.c
index 62800ad66f2..05b34269b5a 100644
--- a/src/backend/port/win32_latch.c
+++ b/src/backend/port/win32_latch.c
@@ -106,6 +106,8 @@ WaitLatchOrSocket(volatile Latch *latch, int wakeEvents, pgsocket sock,
wakeEvents &= ~(WL_SOCKET_READABLE | WL_SOCKET_WRITEABLE);
Assert(wakeEvents != 0); /* must have at least one wake event */
+ /* Cannot specify WL_SOCKET_WRITEABLE without WL_SOCKET_READABLE */
+ Assert((wakeEvents & (WL_SOCKET_READABLE | WL_SOCKET_WRITEABLE)) != WL_SOCKET_WRITEABLE);
if ((wakeEvents & WL_LATCH_SET) && latch->owner_pid != MyProcPid)
elog(ERROR, "cannot wait on a latch owned by another process");