Skip to content

Commit 6bc4d95

Browse files
committed
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: 20160114143931.GG10941@awork2.anarazel.de 20151230173734.hx7jj2fnwyljfqek@alap3.anarazel.de Reviewed-By: Robert Haas
1 parent fad0f9d commit 6bc4d95

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/backend/port/unix_latch.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,13 @@ WaitLatchOrSocket(volatile Latch *latch, int wakeEvents, pgsocket sock,
226226
int hifd;
227227
#endif
228228

229-
/* Ignore WL_SOCKET_* events if no valid socket is given */
230-
if (sock == PGINVALID_SOCKET)
231-
wakeEvents &= ~(WL_SOCKET_READABLE | WL_SOCKET_WRITEABLE);
232-
233229
Assert(wakeEvents != 0); /* must have at least one wake event */
234230

231+
/* waiting for socket readiness without a socket indicates a bug */
232+
if (sock == PGINVALID_SOCKET &&
233+
(wakeEvents & (WL_SOCKET_READABLE | WL_SOCKET_WRITEABLE)) != 0)
234+
elog(ERROR, "cannot wait on socket event without a socket");
235+
235236
if ((wakeEvents & WL_LATCH_SET) && latch->owner_pid != MyProcPid)
236237
elog(ERROR, "cannot wait on a latch owned by another process");
237238

src/backend/port/win32_latch.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,13 @@ WaitLatchOrSocket(volatile Latch *latch, int wakeEvents, pgsocket sock,
113113
int result = 0;
114114
int pmdeath_eventno = 0;
115115

116-
/* Ignore WL_SOCKET_* events if no valid socket is given */
117-
if (sock == PGINVALID_SOCKET)
118-
wakeEvents &= ~(WL_SOCKET_READABLE | WL_SOCKET_WRITEABLE);
119-
120116
Assert(wakeEvents != 0); /* must have at least one wake event */
121117

118+
/* waiting for socket readiness without a socket indicates a bug */
119+
if (sock == PGINVALID_SOCKET &&
120+
(wakeEvents & (WL_SOCKET_READABLE | WL_SOCKET_WRITEABLE)) != 0)
121+
elog(ERROR, "cannot wait on socket event without a socket");
122+
122123
if ((wakeEvents & WL_LATCH_SET) && latch->owner_pid != MyProcPid)
123124
elog(ERROR, "cannot wait on a latch owned by another process");
124125

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy