Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit bda6e04

Browse files
committed
Check for EOF on pipe differs under win32, as it is based on a socket
implementation. Claudio Natoli
1 parent f744c0f commit bda6e04

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/backend/postmaster/pgstat.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
* Copyright (c) 2001-2003, PostgreSQL Global Development Group
1515
*
16-
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.60 2004/03/10 21:12:46 momjian Exp $
16+
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.61 2004/03/15 16:21:37 momjian Exp $
1717
* ----------
1818
*/
1919
#include "postgres.h"
@@ -1642,6 +1642,7 @@ pgstat_mainChild(PGSTAT_FORK_ARGS)
16421642
*/
16431643
int nread = 0;
16441644
int targetlen = sizeof(PgStat_MsgHdr); /* initial */
1645+
bool pipeEOF = false;
16451646

16461647
while (nread < targetlen)
16471648
{
@@ -1652,13 +1653,23 @@ pgstat_mainChild(PGSTAT_FORK_ARGS)
16521653
{
16531654
if (errno == EINTR)
16541655
continue;
1656+
#ifdef WIN32
1657+
if (WSAGetLastError() == WSAECONNRESET) /* EOF on the pipe! (win32 socket based implementation) */
1658+
{
1659+
pipeEOF = true;
1660+
break;
1661+
}
1662+
#endif
16551663
ereport(LOG,
16561664
(errcode_for_socket_access(),
1657-
errmsg("could not read from statistics collector pipe: %m")));
1665+
errmsg("could not read from statistics collector pipe: %m")));
16581666
exit(1);
16591667
}
16601668
if (len == 0) /* EOF on the pipe! */
1669+
{
1670+
pipeEOF = true;
16611671
break;
1672+
}
16621673
nread += len;
16631674
if (nread == sizeof(PgStat_MsgHdr))
16641675
{
@@ -1683,7 +1694,7 @@ pgstat_mainChild(PGSTAT_FORK_ARGS)
16831694
* EOF on the pipe implies that the buffer process exited.
16841695
* Fall out of outer loop.
16851696
*/
1686-
if (len == 0)
1697+
if (pipeEOF)
16871698
break;
16881699

16891700
/*

0 commit comments

Comments
 (0)