13
13
*
14
14
* Copyright (c) 2001-2010, PostgreSQL Global Development Group
15
15
*
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 $
17
17
* ----------
18
18
*/
19
19
#include "postgres.h"
@@ -353,7 +353,7 @@ pgstat_init(void)
353
353
/*
354
354
* Create the socket.
355
355
*/
356
- if ((pgStatSock = socket (addr -> ai_family , SOCK_DGRAM , 0 )) < 0 )
356
+ if ((pgStatSock = socket (addr -> ai_family , SOCK_DGRAM , 0 )) == PGINVALID_SOCKET )
357
357
{
358
358
ereport (LOG ,
359
359
(errcode_for_socket_access (),
@@ -494,7 +494,7 @@ pgstat_init(void)
494
494
}
495
495
496
496
/* Did we find a working address? */
497
- if (!addr || pgStatSock < 0 )
497
+ if (!addr || pgStatSock == PGINVALID_SOCKET )
498
498
goto startup_failed ;
499
499
500
500
/*
@@ -521,7 +521,7 @@ pgstat_init(void)
521
521
if (addrs )
522
522
pg_freeaddrinfo_all (hints .ai_family , addrs );
523
523
524
- if (pgStatSock >= 0 )
524
+ if (pgStatSock != PGINVALID_SOCKET )
525
525
closesocket (pgStatSock );
526
526
pgStatSock = PGINVALID_SOCKET ;
527
527
@@ -592,7 +592,7 @@ pgstat_start(void)
592
592
* Check that the socket is there, else pgstat_init failed and we can do
593
593
* nothing useful.
594
594
*/
595
- if (pgStatSock < 0 )
595
+ if (pgStatSock == PGINVALID_SOCKET )
596
596
return 0 ;
597
597
598
598
/*
@@ -768,7 +768,7 @@ pgstat_send_tabstat(PgStat_MsgTabstat *tsmsg)
768
768
int len ;
769
769
770
770
/* It's unlikely we'd get here with no socket, but maybe not impossible */
771
- if (pgStatSock < 0 )
771
+ if (pgStatSock == PGINVALID_SOCKET )
772
772
return ;
773
773
774
774
/*
@@ -870,7 +870,7 @@ pgstat_vacuum_stat(void)
870
870
PgStat_StatFuncEntry * funcentry ;
871
871
int len ;
872
872
873
- if (pgStatSock < 0 )
873
+ if (pgStatSock == PGINVALID_SOCKET )
874
874
return ;
875
875
876
876
/*
@@ -1089,7 +1089,7 @@ pgstat_drop_database(Oid databaseid)
1089
1089
{
1090
1090
PgStat_MsgDropdb msg ;
1091
1091
1092
- if (pgStatSock < 0 )
1092
+ if (pgStatSock == PGINVALID_SOCKET )
1093
1093
return ;
1094
1094
1095
1095
pgstat_setheader (& msg .m_hdr , PGSTAT_MTYPE_DROPDB );
@@ -1116,7 +1116,7 @@ pgstat_drop_relation(Oid relid)
1116
1116
PgStat_MsgTabpurge msg ;
1117
1117
int len ;
1118
1118
1119
- if (pgStatSock < 0 )
1119
+ if (pgStatSock == PGINVALID_SOCKET )
1120
1120
return ;
1121
1121
1122
1122
msg .m_tableid [0 ] = relid ;
@@ -1142,7 +1142,7 @@ pgstat_reset_counters(void)
1142
1142
{
1143
1143
PgStat_MsgResetcounter msg ;
1144
1144
1145
- if (pgStatSock < 0 )
1145
+ if (pgStatSock == PGINVALID_SOCKET )
1146
1146
return ;
1147
1147
1148
1148
if (!superuser ())
@@ -1166,7 +1166,7 @@ pgstat_reset_shared_counters(const char *target)
1166
1166
{
1167
1167
PgStat_MsgResetsharedcounter msg ;
1168
1168
1169
- if (pgStatSock < 0 )
1169
+ if (pgStatSock == PGINVALID_SOCKET )
1170
1170
return ;
1171
1171
1172
1172
if (!superuser ())
@@ -1198,7 +1198,7 @@ void pgstat_reset_single_counter(Oid objoid, PgStat_Single_Reset_Type type)
1198
1198
{
1199
1199
PgStat_MsgResetsinglecounter msg ;
1200
1200
1201
- if (pgStatSock < 0 )
1201
+ if (pgStatSock == PGINVALID_SOCKET )
1202
1202
return ;
1203
1203
1204
1204
if (!superuser ())
@@ -1227,7 +1227,7 @@ pgstat_report_autovac(Oid dboid)
1227
1227
{
1228
1228
PgStat_MsgAutovacStart msg ;
1229
1229
1230
- if (pgStatSock < 0 )
1230
+ if (pgStatSock == PGINVALID_SOCKET )
1231
1231
return ;
1232
1232
1233
1233
pgstat_setheader (& msg .m_hdr , PGSTAT_MTYPE_AUTOVAC_START );
@@ -1250,7 +1250,7 @@ pgstat_report_vacuum(Oid tableoid, bool shared, bool adopt_counts,
1250
1250
{
1251
1251
PgStat_MsgVacuum msg ;
1252
1252
1253
- if (pgStatSock < 0 || !pgstat_track_counts )
1253
+ if (pgStatSock == PGINVALID_SOCKET || !pgstat_track_counts )
1254
1254
return ;
1255
1255
1256
1256
pgstat_setheader (& msg .m_hdr , PGSTAT_MTYPE_VACUUM );
@@ -1275,7 +1275,7 @@ pgstat_report_analyze(Relation rel, bool adopt_counts,
1275
1275
{
1276
1276
PgStat_MsgAnalyze msg ;
1277
1277
1278
- if (pgStatSock < 0 || !pgstat_track_counts )
1278
+ if (pgStatSock == PGINVALID_SOCKET || !pgstat_track_counts )
1279
1279
return ;
1280
1280
1281
1281
/*
@@ -1327,7 +1327,7 @@ pgstat_ping(void)
1327
1327
{
1328
1328
PgStat_MsgDummy msg ;
1329
1329
1330
- if (pgStatSock < 0 )
1330
+ if (pgStatSock == PGINVALID_SOCKET )
1331
1331
return ;
1332
1332
1333
1333
pgstat_setheader (& msg .m_hdr , PGSTAT_MTYPE_DUMMY );
@@ -1485,7 +1485,7 @@ pgstat_initstats(Relation rel)
1485
1485
return ;
1486
1486
}
1487
1487
1488
- if (pgStatSock < 0 || !pgstat_track_counts )
1488
+ if (pgStatSock == PGINVALID_SOCKET || !pgstat_track_counts )
1489
1489
{
1490
1490
/* We're not counting at all */
1491
1491
rel -> pgstat_info = NULL ;
@@ -2691,7 +2691,7 @@ pgstat_send(void *msg, int len)
2691
2691
{
2692
2692
int rc ;
2693
2693
2694
- if (pgStatSock < 0 )
2694
+ if (pgStatSock == PGINVALID_SOCKET )
2695
2695
return ;
2696
2696
2697
2697
((PgStat_MsgHdr * ) msg )-> m_size = len ;
0 commit comments