aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2012-05-14 23:51:34 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2012-05-14 23:51:34 -0400
commit9b63e9869ffaa4d6d3e8bf45086a765d8f310f1c (patch)
tree0614e22273530b7b8d7316e8b2a0baf682dfdbd4 /src
parent5a2bb060121f574d6587e5fc6c7f1d4e3a759351 (diff)
downloadpostgresql-9b63e9869ffaa4d6d3e8bf45086a765d8f310f1c.tar.gz
postgresql-9b63e9869ffaa4d6d3e8bf45086a765d8f310f1c.zip
In pgstat.c, use a timeout in WaitLatchOrSocket only on Windows.
We have no need for a timeout here really, but some broken products from Redmond seem to lose FD_READ events occasionally, and waking up and retrying the recv() is the only known way to work around that. Perhaps somebody will be motivated to figure out a better answer here; but not I.
Diffstat (limited to 'src')
-rw-r--r--src/backend/postmaster/pgstat.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index bb7c61b058b..424cfcaf4f7 100644
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -3113,7 +3113,8 @@ PgstatCollectorMain(int argc, char *argv[])
* Try to receive and process a message. This will not block,
* since the socket is set to non-blocking mode.
*
- * XXX On Windows, we have to force pgwin32_recv to cooperate.
+ * XXX On Windows, we have to force pgwin32_recv to cooperate,
+ * despite the previous use of pg_set_noblock() on the socket.
* This is extremely broken and should be fixed someday.
*/
#ifdef WIN32
@@ -3231,11 +3232,27 @@ PgstatCollectorMain(int argc, char *argv[])
} /* end of inner message-processing loop */
/* Sleep until there's something to do */
- /* XXX should not need a timeout here */
+#ifndef WIN32
+ wr = WaitLatchOrSocket(&pgStatLatch,
+ WL_LATCH_SET | WL_POSTMASTER_DEATH | WL_SOCKET_READABLE,
+ pgStatSock,
+ -1L);
+#else
+ /*
+ * Windows, at least in its Windows Server 2003 R2 incarnation,
+ * sometimes loses FD_READ events. Waking up and retrying the recv()
+ * fixes that, so don't sleep indefinitely. This is a crock of the
+ * first water, but until somebody wants to debug exactly what's
+ * happening there, this is the best we can do. The two-second
+ * timeout matches our pre-9.2 behavior, and needs to be short enough
+ * to not provoke "pgstat wait timeout" complaints from
+ * backend_read_statsfile.
+ */
wr = WaitLatchOrSocket(&pgStatLatch,
WL_LATCH_SET | WL_POSTMASTER_DEATH | WL_SOCKET_READABLE | WL_TIMEOUT,
pgStatSock,
- 2000L);
+ 2 * 1000L /* msec */);
+#endif
/*
* Emergency bailout if postmaster has died. This is to avoid the