3737 *
3838 *
3939 * IDENTIFICATION
40- * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.599 2010/01/02 16:57:50 momjian Exp $
40+ * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.600 2010/01/10 14: 16:08 mha Exp $
4141 *
4242 * NOTES
4343 *
@@ -172,7 +172,7 @@ int ReservedBackends;
172172
173173/* The socket(s) we're listening to. */
174174#define MAXLISTEN 64
175- static int ListenSocket [MAXLISTEN ];
175+ static pgsocket ListenSocket [MAXLISTEN ];
176176
177177/*
178178 * Set by the -o option
@@ -382,7 +382,7 @@ static pid_t internal_forkexec(int argc, char *argv[], Port *port);
382382#ifdef WIN32
383383typedef struct
384384{
385- SOCKET origsocket ; /* Original socket value, or -1 if not a
385+ SOCKET origsocket ; /* Original socket value, or PGINVALID_SOCKET if not a
386386 * socket */
387387 WSAPROTOCOL_INFO wsainfo ;
388388} InheritableSocket ;
@@ -400,7 +400,7 @@ typedef struct
400400 Port port ;
401401 InheritableSocket portsocket ;
402402 char DataDir [MAXPGPATH ];
403- int ListenSocket [MAXLISTEN ];
403+ pgsocket ListenSocket [MAXLISTEN ];
404404 long MyCancelKey ;
405405 int MyPMChildSlot ;
406406#ifndef WIN32
@@ -807,7 +807,7 @@ PostmasterMain(int argc, char *argv[])
807807 * Establish input sockets.
808808 */
809809 for (i = 0 ; i < MAXLISTEN ; i ++ )
810- ListenSocket [i ] = -1 ;
810+ ListenSocket [i ] = PGINVALID_SOCKET ;
811811
812812 if (ListenAddresses )
813813 {
@@ -860,7 +860,7 @@ PostmasterMain(int argc, char *argv[])
860860
861861#ifdef USE_BONJOUR
862862 /* Register for Bonjour only if we opened TCP socket(s) */
863- if (enable_bonjour && ListenSocket [0 ] != -1 )
863+ if (enable_bonjour && ListenSocket [0 ] != PGINVALID_SOCKET )
864864 {
865865 DNSServiceErrorType err ;
866866
@@ -908,7 +908,7 @@ PostmasterMain(int argc, char *argv[])
908908 /*
909909 * check that we have some socket to listen on
910910 */
911- if (ListenSocket [0 ] == -1 )
911+ if (ListenSocket [0 ] == PGINVALID_SOCKET )
912912 ereport (FATAL ,
913913 (errmsg ("no socket created for listening" )));
914914
@@ -1392,7 +1392,7 @@ ServerLoop(void)
13921392
13931393 for (i = 0 ; i < MAXLISTEN ; i ++ )
13941394 {
1395- if (ListenSocket [i ] == -1 )
1395+ if (ListenSocket [i ] == PGINVALID_SOCKET )
13961396 break ;
13971397 if (FD_ISSET (ListenSocket [i ], & rmask ))
13981398 {
@@ -1493,7 +1493,7 @@ initMasks(fd_set *rmask)
14931493 {
14941494 int fd = ListenSocket [i ];
14951495
1496- if (fd == -1 )
1496+ if (fd == PGINVALID_SOCKET )
14971497 break ;
14981498 FD_SET (fd , rmask );
14991499
@@ -2002,10 +2002,10 @@ ClosePostmasterPorts(bool am_syslogger)
20022002 /* Close the listen sockets */
20032003 for (i = 0 ; i < MAXLISTEN ; i ++ )
20042004 {
2005- if (ListenSocket [i ] != -1 )
2005+ if (ListenSocket [i ] != PGINVALID_SOCKET )
20062006 {
20072007 StreamClose (ListenSocket [i ]);
2008- ListenSocket [i ] = -1 ;
2008+ ListenSocket [i ] = PGINVALID_SOCKET ;
20092009 }
20102010 }
20112011
@@ -4408,7 +4408,7 @@ extern slock_t *ProcStructLock;
44084408extern PROC_HDR * ProcGlobal ;
44094409extern PGPROC * AuxiliaryProcs ;
44104410extern PMSignalData * PMSignalState ;
4411- extern int pgStatSock ;
4411+ extern pgsocket pgStatSock ;
44124412
44134413#ifndef WIN32
44144414#define write_inheritable_socket (dest , src , childpid ) ((*(dest) = (src)), true)
@@ -4522,7 +4522,7 @@ static bool
45224522write_inheritable_socket (InheritableSocket * dest , SOCKET src , pid_t childpid )
45234523{
45244524 dest -> origsocket = src ;
4525- if (src != 0 && src != -1 )
4525+ if (src != 0 && src != PGINVALID_SOCKET )
45264526 {
45274527 /* Actual socket */
45284528 if (WSADuplicateSocket (src , childpid , & dest -> wsainfo ) != 0 )
@@ -4544,7 +4544,7 @@ read_inheritable_socket(SOCKET *dest, InheritableSocket *src)
45444544{
45454545 SOCKET s ;
45464546
4547- if (src -> origsocket == -1 || src -> origsocket == 0 )
4547+ if (src -> origsocket == PGINVALID_SOCKET || src -> origsocket == 0 )
45484548 {
45494549 /* Not a real socket! */
45504550 * dest = src -> origsocket ;
0 commit comments