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{
358358ereport (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 )
498498gotostartup_failed ;
499499
500500/*
@@ -521,7 +521,7 @@ pgstat_init(void)
521521if (addrs )
522522pg_freeaddrinfo_all (hints .ai_family ,addrs );
523523
524- if (pgStatSock >= 0 )
524+ if (pgStatSock != PGINVALID_SOCKET )
525525closesocket (pgStatSock );
526526pgStatSock = 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 )
596596return 0 ;
597597
598598/*
@@ -768,7 +768,7 @@ pgstat_send_tabstat(PgStat_MsgTabstat *tsmsg)
768768int 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 )
772772return ;
773773
774774/*
@@ -870,7 +870,7 @@ pgstat_vacuum_stat(void)
870870PgStat_StatFuncEntry * funcentry ;
871871int len ;
872872
873- if (pgStatSock < 0 )
873+ if (pgStatSock == PGINVALID_SOCKET )
874874return ;
875875
876876/*
@@ -1089,7 +1089,7 @@ pgstat_drop_database(Oid databaseid)
10891089{
10901090PgStat_MsgDropdb msg ;
10911091
1092- if (pgStatSock < 0 )
1092+ if (pgStatSock == PGINVALID_SOCKET )
10931093return ;
10941094
10951095pgstat_setheader (& msg .m_hdr ,PGSTAT_MTYPE_DROPDB );
@@ -1116,7 +1116,7 @@ pgstat_drop_relation(Oid relid)
11161116PgStat_MsgTabpurge msg ;
11171117int len ;
11181118
1119- if (pgStatSock < 0 )
1119+ if (pgStatSock == PGINVALID_SOCKET )
11201120return ;
11211121
11221122msg .m_tableid [0 ]= relid ;
@@ -1142,7 +1142,7 @@ pgstat_reset_counters(void)
11421142{
11431143PgStat_MsgResetcounter msg ;
11441144
1145- if (pgStatSock < 0 )
1145+ if (pgStatSock == PGINVALID_SOCKET )
11461146return ;
11471147
11481148if (!superuser ())
@@ -1166,7 +1166,7 @@ pgstat_reset_shared_counters(const char *target)
11661166{
11671167PgStat_MsgResetsharedcounter msg ;
11681168
1169- if (pgStatSock < 0 )
1169+ if (pgStatSock == PGINVALID_SOCKET )
11701170return ;
11711171
11721172if (!superuser ())
@@ -1198,7 +1198,7 @@ void pgstat_reset_single_counter(Oid objoid, PgStat_Single_Reset_Type type)
11981198{
11991199PgStat_MsgResetsinglecounter msg ;
12001200
1201- if (pgStatSock < 0 )
1201+ if (pgStatSock == PGINVALID_SOCKET )
12021202return ;
12031203
12041204if (!superuser ())
@@ -1227,7 +1227,7 @@ pgstat_report_autovac(Oid dboid)
12271227{
12281228PgStat_MsgAutovacStart msg ;
12291229
1230- if (pgStatSock < 0 )
1230+ if (pgStatSock == PGINVALID_SOCKET )
12311231return ;
12321232
12331233pgstat_setheader (& msg .m_hdr ,PGSTAT_MTYPE_AUTOVAC_START );
@@ -1250,7 +1250,7 @@ pgstat_report_vacuum(Oid tableoid, bool shared, bool adopt_counts,
12501250{
12511251PgStat_MsgVacuum msg ;
12521252
1253- if (pgStatSock < 0 || !pgstat_track_counts )
1253+ if (pgStatSock == PGINVALID_SOCKET || !pgstat_track_counts )
12541254return ;
12551255
12561256pgstat_setheader (& msg .m_hdr ,PGSTAT_MTYPE_VACUUM );
@@ -1275,7 +1275,7 @@ pgstat_report_analyze(Relation rel, bool adopt_counts,
12751275{
12761276PgStat_MsgAnalyze msg ;
12771277
1278- if (pgStatSock < 0 || !pgstat_track_counts )
1278+ if (pgStatSock == PGINVALID_SOCKET || !pgstat_track_counts )
12791279return ;
12801280
12811281/*
@@ -1327,7 +1327,7 @@ pgstat_ping(void)
13271327{
13281328PgStat_MsgDummy msg ;
13291329
1330- if (pgStatSock < 0 )
1330+ if (pgStatSock == PGINVALID_SOCKET )
13311331return ;
13321332
13331333pgstat_setheader (& msg .m_hdr ,PGSTAT_MTYPE_DUMMY );
@@ -1485,7 +1485,7 @@ pgstat_initstats(Relation rel)
14851485return ;
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 */
14911491rel -> pgstat_info = NULL ;
@@ -2691,7 +2691,7 @@ pgstat_send(void *msg, int len)
26912691{
26922692int rc ;
26932693
2694- if (pgStatSock < 0 )
2694+ if (pgStatSock == PGINVALID_SOCKET )
26952695return ;
26962696
26972697((PgStat_MsgHdr * )msg )-> m_size = len ;