mirror of
https://github.com/postgres/postgres.git
synced 2025-06-26 12:21:12 +03:00
Force pgwin32_recv into nonblock mode when called from pgstat.c.
This should get rid of the usage of pgwin32_waitforsinglesocket entirely, and perhaps thereby remove the race condition that's evidently still present on some versions of Windows. The previous arrangement was a bit unsafe anyway, since waiting at the recv() would not allow pgstat to notice postmaster death.
This commit is contained in:
@ -3117,9 +3117,21 @@ PgstatCollectorMain(int argc, char *argv[])
|
|||||||
/*
|
/*
|
||||||
* Try to receive and process a message. This will not block,
|
* Try to receive and process a message. This will not block,
|
||||||
* since the socket is set to non-blocking mode.
|
* since the socket is set to non-blocking mode.
|
||||||
|
*
|
||||||
|
* XXX On Windows, we have to force pgwin32_recv to cooperate.
|
||||||
|
* This is extremely broken and should be fixed someday.
|
||||||
*/
|
*/
|
||||||
|
#ifdef WIN32
|
||||||
|
pgwin32_noblock = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
len = recv(pgStatSock, (char *) &msg,
|
len = recv(pgStatSock, (char *) &msg,
|
||||||
sizeof(PgStat_Msg), 0);
|
sizeof(PgStat_Msg), 0);
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
pgwin32_noblock = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
{
|
{
|
||||||
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR)
|
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR)
|
||||||
|
Reference in New Issue
Block a user