Skip to content

Commit 6cd2c9f

Browse files
committed
Ensure that 'disabling statistics collector' is logged in all failure
paths of pgstat_init. Responds to confusion exhibited by Christoph Haller.
1 parent ed06824 commit 6cd2c9f

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/backend/postmaster/pgstat.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
* Copyright (c) 2001-2004, PostgreSQL Global Development Group
1515
*
16-
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.85 2004/11/17 00:14:12 tgl Exp $
16+
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.86 2004/12/20 19:17:56 tgl Exp $
1717
* ----------
1818
*/
1919
#include "postgres.h"
@@ -379,7 +379,7 @@ pgstat_init(void)
379379
* errno will not be set meaningfully here, so don't use it.
380380
*/
381381
ereport(LOG,
382-
(ERRCODE_CONNECTION_FAILURE,
382+
(errcode(ERRCODE_CONNECTION_FAILURE),
383383
errmsg("test message did not get through on socket for statistics collector")));
384384
closesocket(pgStatSock);
385385
pgStatSock = -1;
@@ -401,7 +401,7 @@ pgstat_init(void)
401401
if (test_byte != TESTBYTEVAL) /* strictly paranoia ... */
402402
{
403403
ereport(LOG,
404-
(ERRCODE_INTERNAL_ERROR,
404+
(errcode(ERRCODE_INTERNAL_ERROR),
405405
errmsg("incorrect test message transmission on socket for statistics collector")));
406406
closesocket(pgStatSock);
407407
pgStatSock = -1;
@@ -414,12 +414,7 @@ pgstat_init(void)
414414

415415
/* Did we find a working address? */
416416
if (!addr || pgStatSock < 0)
417-
{
418-
ereport(LOG,
419-
(errcode_for_socket_access(),
420-
errmsg("disabling statistics collector for lack of working socket")));
421417
goto startup_failed;
422-
}
423418

424419
/*
425420
* Set the socket to non-blocking IO. This ensures that if the
@@ -440,6 +435,9 @@ pgstat_init(void)
440435
return;
441436

442437
startup_failed:
438+
ereport(LOG,
439+
(errmsg("disabling statistics collector for lack of working socket")));
440+
443441
if (addrs)
444442
freeaddrinfo_all(hints.ai_family, addrs);
445443

0 commit comments

Comments
 (0)