1313 *
1414 * Copyright (c) 2001-2010, PostgreSQL Global Development Group
1515 *
16- * $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.199 2010/01/28 14:25:41 mha Exp $
16+ * $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.200 2010/01/31 17:39:34 mha Exp $
1717 * ----------
1818 */
1919#include "postgres.h"
@@ -353,7 +353,7 @@ pgstat_init(void)
353353 /*
354354 * Create the socket.
355355 */
356- if ((pgStatSock = socket (addr -> ai_family , SOCK_DGRAM , 0 )) < 0 )
356+ if ((pgStatSock = socket (addr -> ai_family , SOCK_DGRAM , 0 )) == PGINVALID_SOCKET )
357357 {
358358 ereport (LOG ,
359359 (errcode_for_socket_access (),
@@ -494,7 +494,7 @@ pgstat_init(void)
494494 }
495495
496496 /* Did we find a working address? */
497- if (!addr || pgStatSock < 0 )
497+ if (!addr || pgStatSock == PGINVALID_SOCKET )
498498 goto startup_failed ;
499499
500500 /*
@@ -521,7 +521,7 @@ pgstat_init(void)
521521 if (addrs )
522522 pg_freeaddrinfo_all (hints .ai_family , addrs );
523523
524- if (pgStatSock >= 0 )
524+ if (pgStatSock != PGINVALID_SOCKET )
525525 closesocket (pgStatSock );
526526 pgStatSock = PGINVALID_SOCKET ;
527527
@@ -592,7 +592,7 @@ pgstat_start(void)
592592 * Check that the socket is there, else pgstat_init failed and we can do
593593 * nothing useful.
594594 */
595- if (pgStatSock < 0 )
595+ if (pgStatSock == PGINVALID_SOCKET )
596596 return 0 ;
597597
598598 /*
@@ -768,7 +768,7 @@ pgstat_send_tabstat(PgStat_MsgTabstat *tsmsg)
768768 int len ;
769769
770770 /* It's unlikely we'd get here with no socket, but maybe not impossible */
771- if (pgStatSock < 0 )
771+ if (pgStatSock == PGINVALID_SOCKET )
772772 return ;
773773
774774 /*
@@ -870,7 +870,7 @@ pgstat_vacuum_stat(void)
870870 PgStat_StatFuncEntry * funcentry ;
871871 int len ;
872872
873- if (pgStatSock < 0 )
873+ if (pgStatSock == PGINVALID_SOCKET )
874874 return ;
875875
876876 /*
@@ -1089,7 +1089,7 @@ pgstat_drop_database(Oid databaseid)
10891089{
10901090 PgStat_MsgDropdb msg ;
10911091
1092- if (pgStatSock < 0 )
1092+ if (pgStatSock == PGINVALID_SOCKET )
10931093 return ;
10941094
10951095 pgstat_setheader (& msg .m_hdr , PGSTAT_MTYPE_DROPDB );
@@ -1116,7 +1116,7 @@ pgstat_drop_relation(Oid relid)
11161116 PgStat_MsgTabpurge msg ;
11171117 int len ;
11181118
1119- if (pgStatSock < 0 )
1119+ if (pgStatSock == PGINVALID_SOCKET )
11201120 return ;
11211121
11221122 msg .m_tableid [0 ] = relid ;
@@ -1142,7 +1142,7 @@ pgstat_reset_counters(void)
11421142{
11431143 PgStat_MsgResetcounter msg ;
11441144
1145- if (pgStatSock < 0 )
1145+ if (pgStatSock == PGINVALID_SOCKET )
11461146 return ;
11471147
11481148 if (!superuser ())
@@ -1166,7 +1166,7 @@ pgstat_reset_shared_counters(const char *target)
11661166{
11671167 PgStat_MsgResetsharedcounter msg ;
11681168
1169- if (pgStatSock < 0 )
1169+ if (pgStatSock == PGINVALID_SOCKET )
11701170 return ;
11711171
11721172 if (!superuser ())
@@ -1198,7 +1198,7 @@ void pgstat_reset_single_counter(Oid objoid, PgStat_Single_Reset_Type type)
11981198{
11991199 PgStat_MsgResetsinglecounter msg ;
12001200
1201- if (pgStatSock < 0 )
1201+ if (pgStatSock == PGINVALID_SOCKET )
12021202 return ;
12031203
12041204 if (!superuser ())
@@ -1227,7 +1227,7 @@ pgstat_report_autovac(Oid dboid)
12271227{
12281228 PgStat_MsgAutovacStart msg ;
12291229
1230- if (pgStatSock < 0 )
1230+ if (pgStatSock == PGINVALID_SOCKET )
12311231 return ;
12321232
12331233 pgstat_setheader (& msg .m_hdr , PGSTAT_MTYPE_AUTOVAC_START );
@@ -1250,7 +1250,7 @@ pgstat_report_vacuum(Oid tableoid, bool shared, bool adopt_counts,
12501250{
12511251 PgStat_MsgVacuum msg ;
12521252
1253- if (pgStatSock < 0 || !pgstat_track_counts )
1253+ if (pgStatSock == PGINVALID_SOCKET || !pgstat_track_counts )
12541254 return ;
12551255
12561256 pgstat_setheader (& msg .m_hdr , PGSTAT_MTYPE_VACUUM );
@@ -1275,7 +1275,7 @@ pgstat_report_analyze(Relation rel, bool adopt_counts,
12751275{
12761276 PgStat_MsgAnalyze msg ;
12771277
1278- if (pgStatSock < 0 || !pgstat_track_counts )
1278+ if (pgStatSock == PGINVALID_SOCKET || !pgstat_track_counts )
12791279 return ;
12801280
12811281 /*
@@ -1327,7 +1327,7 @@ pgstat_ping(void)
13271327{
13281328 PgStat_MsgDummy msg ;
13291329
1330- if (pgStatSock < 0 )
1330+ if (pgStatSock == PGINVALID_SOCKET )
13311331 return ;
13321332
13331333 pgstat_setheader (& msg .m_hdr , PGSTAT_MTYPE_DUMMY );
@@ -1485,7 +1485,7 @@ pgstat_initstats(Relation rel)
14851485 return ;
14861486 }
14871487
1488- if (pgStatSock < 0 || !pgstat_track_counts )
1488+ if (pgStatSock == PGINVALID_SOCKET || !pgstat_track_counts )
14891489 {
14901490 /* We're not counting at all */
14911491 rel -> pgstat_info = NULL ;
@@ -2691,7 +2691,7 @@ pgstat_send(void *msg, int len)
26912691{
26922692 int rc ;
26932693
2694- if (pgStatSock < 0 )
2694+ if (pgStatSock == PGINVALID_SOCKET )
26952695 return ;
26962696
26972697 ((PgStat_MsgHdr * ) msg )-> m_size = len ;
0 commit comments