Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit87091cb

Browse files
committed
Create typedef pgsocket for storing socket descriptors.
This silences some warnings on Win64. Not using the proper SOCKET datatypewas actually wrong on Win32 as well, but didn't cause any warnings there.Also create define PGINVALID_SOCKET to indicate an invalid/non-existingsocket, instead of using a hardcoded -1 value.
1 parent84b6d5f commit87091cb

File tree

9 files changed

+61
-52
lines changed

9 files changed

+61
-52
lines changed

‎src/backend/libpq/auth.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/libpq/auth.c,v 1.190 2010/01/0216:57:45 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/libpq/auth.c,v 1.191 2010/01/10 14:16:07 mha Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1497,7 +1497,7 @@ ident_inet(const SockAddr remote_addr,
14971497
constSockAddrlocal_addr,
14981498
char*ident_user)
14991499
{
1500-
intsock_fd,/* File descriptor for socket on which we talk
1500+
pgsocketsock_fd,/* File descriptor for socket on which we talk
15011501
* to Ident */
15021502
rc;/* Return code from a locally called function */
15031503
boolident_return;

‎src/backend/libpq/ip.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/libpq/ip.c,v 1.49 2010/01/0216:57:45 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/libpq/ip.c,v 1.50 2010/01/10 14:16:07 mha Exp $
1212
*
1313
* This file and the IPV6 implementation were initially provided by
1414
* Nigel Kukard <nkukard@lbsd.net>, Linux Based Systems Design
@@ -656,9 +656,9 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data)
656656
structsockaddr*addr,*mask;
657657
char*ptr,*buffer=NULL;
658658
size_tn_buffer=1024;
659-
intsock,fd;
659+
pgsocketsock,fd;
660660
#ifdefHAVE_IPV6
661-
intsock6;
661+
pgsocketsock6;
662662
#endif
663663
inti,total;
664664

‎src/backend/libpq/pqcomm.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
3131
* Portions Copyright (c) 1994, Regents of the University of California
3232
*
33-
*$PostgreSQL: pgsql/src/backend/libpq/pqcomm.c,v 1.200 2010/01/0216:57:45 momjian Exp $
33+
*$PostgreSQL: pgsql/src/backend/libpq/pqcomm.c,v 1.201 2010/01/10 14:16:07 mha Exp $
3434
*
3535
*-------------------------------------------------------------------------
3636
*/
@@ -199,9 +199,9 @@ pq_close(int code, Datum arg)
199199
* transport layer reports connection closure, and you can be sure the
200200
* backend has exited.
201201
*
202-
* We do set sock to-1 to prevent any further I/O, though.
202+
* We do set sock toPGINVALID_SOCKET to prevent any further I/O, though.
203203
*/
204-
MyProcPort->sock=-1;
204+
MyProcPort->sock=PGINVALID_SOCKET;
205205
}
206206
}
207207

@@ -232,18 +232,18 @@ StreamDoUnlink(int code, Datum arg)
232232
* StreamServerPort -- open a "listening" port to accept connections.
233233
*
234234
* Successfully opened sockets are added to the ListenSocket[] array,
235-
* at the first position that isn't-1.
235+
* at the first position that isn'tPGINVALID_SOCKET.
236236
*
237237
* RETURNS: STATUS_OK or STATUS_ERROR
238238
*/
239239

240240
int
241241
StreamServerPort(intfamily,char*hostName,unsigned shortportNumber,
242242
char*unixSocketName,
243-
intListenSocket[],intMaxListen)
243+
pgsocketListenSocket[],intMaxListen)
244244
{
245-
intfd,
246-
err;
245+
pgsocketfd;
246+
interr;
247247
intmaxconn;
248248
intret;
249249
charportNumberStr[32];
@@ -311,7 +311,7 @@ StreamServerPort(int family, char *hostName, unsigned short portNumber,
311311
/* See if there is still room to add 1 more socket. */
312312
for (;listen_index<MaxListen;listen_index++)
313313
{
314-
if (ListenSocket[listen_index]==-1)
314+
if (ListenSocket[listen_index]==PGINVALID_SOCKET)
315315
break;
316316
}
317317
if (listen_index >=MaxListen)
@@ -570,7 +570,7 @@ Setup_AF_UNIX(void)
570570
* RETURNS: STATUS_OK or STATUS_ERROR
571571
*/
572572
int
573-
StreamConnection(intserver_fd,Port*port)
573+
StreamConnection(pgsocketserver_fd,Port*port)
574574
{
575575
/* accept connection and fill in the client (remote) address */
576576
port->raddr.salen=sizeof(port->raddr.addr);
@@ -676,7 +676,7 @@ StreamConnection(int server_fd, Port *port)
676676
* we do NOT want to send anything to the far end.
677677
*/
678678
void
679-
StreamClose(intsock)
679+
StreamClose(pgsocketsock)
680680
{
681681
closesocket(sock);
682682
}

‎src/backend/postmaster/pgstat.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*Copyright (c) 2001-2010, PostgreSQL Global Development Group
1515
*
16-
*$PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.196 2010/01/0216:57:50 momjian Exp $
16+
*$PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.197 2010/01/10 14:16:07 mha Exp $
1717
* ----------
1818
*/
1919
#include"postgres.h"
@@ -130,7 +130,7 @@ PgStat_MsgBgWriter BgWriterStats;
130130
* Local data
131131
* ----------
132132
*/
133-
NON_EXEC_STATICintpgStatSock=-1;
133+
NON_EXEC_STATICpgsocketpgStatSock=PGINVALID_SOCKET;
134134

135135
staticstructsockaddr_storagepgStatAddr;
136136

@@ -369,7 +369,7 @@ pgstat_init(void)
369369
(errcode_for_socket_access(),
370370
errmsg("could not bind socket for statistics collector: %m")));
371371
closesocket(pgStatSock);
372-
pgStatSock=-1;
372+
pgStatSock=PGINVALID_SOCKET;
373373
continue;
374374
}
375375

@@ -380,7 +380,7 @@ pgstat_init(void)
380380
(errcode_for_socket_access(),
381381
errmsg("could not get address of socket for statistics collector: %m")));
382382
closesocket(pgStatSock);
383-
pgStatSock=-1;
383+
pgStatSock=PGINVALID_SOCKET;
384384
continue;
385385
}
386386

@@ -396,7 +396,7 @@ pgstat_init(void)
396396
(errcode_for_socket_access(),
397397
errmsg("could not connect socket for statistics collector: %m")));
398398
closesocket(pgStatSock);
399-
pgStatSock=-1;
399+
pgStatSock=PGINVALID_SOCKET;
400400
continue;
401401
}
402402

@@ -417,7 +417,7 @@ pgstat_init(void)
417417
(errcode_for_socket_access(),
418418
errmsg("could not send test message on socket for statistics collector: %m")));
419419
closesocket(pgStatSock);
420-
pgStatSock=-1;
420+
pgStatSock=PGINVALID_SOCKET;
421421
continue;
422422
}
423423

@@ -443,7 +443,7 @@ pgstat_init(void)
443443
(errcode_for_socket_access(),
444444
errmsg("select() failed in statistics collector: %m")));
445445
closesocket(pgStatSock);
446-
pgStatSock=-1;
446+
pgStatSock=PGINVALID_SOCKET;
447447
continue;
448448
}
449449
if (sel_res==0|| !FD_ISSET(pgStatSock,&rset))
@@ -458,7 +458,7 @@ pgstat_init(void)
458458
(errcode(ERRCODE_CONNECTION_FAILURE),
459459
errmsg("test message did not get through on socket for statistics collector")));
460460
closesocket(pgStatSock);
461-
pgStatSock=-1;
461+
pgStatSock=PGINVALID_SOCKET;
462462
continue;
463463
}
464464

@@ -473,7 +473,7 @@ pgstat_init(void)
473473
(errcode_for_socket_access(),
474474
errmsg("could not receive test message on socket for statistics collector: %m")));
475475
closesocket(pgStatSock);
476-
pgStatSock=-1;
476+
pgStatSock=PGINVALID_SOCKET;
477477
continue;
478478
}
479479

@@ -483,7 +483,7 @@ pgstat_init(void)
483483
(errcode(ERRCODE_INTERNAL_ERROR),
484484
errmsg("incorrect test message transmission on socket for statistics collector")));
485485
closesocket(pgStatSock);
486-
pgStatSock=-1;
486+
pgStatSock=PGINVALID_SOCKET;
487487
continue;
488488
}
489489

@@ -521,7 +521,7 @@ pgstat_init(void)
521521

522522
if (pgStatSock >=0)
523523
closesocket(pgStatSock);
524-
pgStatSock=-1;
524+
pgStatSock=PGINVALID_SOCKET;
525525

526526
/*
527527
* Adjust GUC variables to suppress useless activity, and for debugging

‎src/backend/postmaster/postmaster.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.599 2010/01/0216: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 @@ intReservedBackends;
172172

173173
/* The socket(s) we're listening to. */
174174
#defineMAXLISTEN64
175-
staticintListenSocket[MAXLISTEN];
175+
staticpgsocketListenSocket[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
#ifdefWIN32
383383
typedefstruct
384384
{
385-
SOCKETorigsocket;/* Original socket value, or-1 if not a
385+
SOCKETorigsocket;/* Original socket value, orPGINVALID_SOCKET if not a
386386
* socket */
387387
WSAPROTOCOL_INFOwsainfo;
388388
}InheritableSocket;
@@ -400,7 +400,7 @@ typedef struct
400400
Portport;
401401
InheritableSocketportsocket;
402402
charDataDir[MAXPGPATH];
403-
intListenSocket[MAXLISTEN];
403+
pgsocketListenSocket[MAXLISTEN];
404404
longMyCancelKey;
405405
intMyPMChildSlot;
406406
#ifndefWIN32
@@ -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
#ifdefUSE_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
DNSServiceErrorTypeerr;
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
intfd=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;
44084408
externPROC_HDR*ProcGlobal;
44094409
externPGPROC*AuxiliaryProcs;
44104410
externPMSignalData*PMSignalState;
4411-
externintpgStatSock;
4411+
externpgsocketpgStatSock;
44124412

44134413
#ifndefWIN32
44144414
#definewrite_inheritable_socket(dest,src,childpid) ((*(dest) = (src)), true)
@@ -4522,7 +4522,7 @@ static bool
45224522
write_inheritable_socket(InheritableSocket*dest,SOCKETsrc,pid_tchildpid)
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
SOCKETs;
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;

‎src/include/libpq/libpq-be.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
1212
* Portions Copyright (c) 1994, Regents of the University of California
1313
*
14-
* $PostgreSQL: pgsql/src/include/libpq/libpq-be.h,v 1.72 2010/01/0216:58:04 momjian Exp $
14+
* $PostgreSQL: pgsql/src/include/libpq/libpq-be.h,v 1.73 2010/01/10 14:16:08 mha Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -103,7 +103,7 @@ typedef struct
103103

104104
typedefstructPort
105105
{
106-
intsock;/* File descriptor */
106+
pgsocketsock;/* File descriptor */
107107
ProtocolVersionproto;/* FE/BE protocol version */
108108
SockAddrladdr;/* local addr (postmaster) */
109109
SockAddrraddr;/* remote addr (client) */

‎src/include/libpq/libpq.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/libpq/libpq.h,v 1.72 2010/01/0216:58:04 momjian Exp $
10+
* $PostgreSQL: pgsql/src/include/libpq/libpq.h,v 1.73 2010/01/10 14:16:08 mha Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -45,10 +45,10 @@ typedef struct
4545
* prototypes for functions in pqcomm.c
4646
*/
4747
externintStreamServerPort(intfamily,char*hostName,
48-
unsigned shortportNumber,char*unixSocketName,intListenSocket[],
48+
unsigned shortportNumber,char*unixSocketName,pgsocketListenSocket[],
4949
intMaxListen);
50-
externintStreamConnection(intserver_fd,Port*port);
51-
externvoidStreamClose(intsock);
50+
externintStreamConnection(pgsocketserver_fd,Port*port);
51+
externvoidStreamClose(pgsocketsock);
5252
externvoidTouchSocketFile(void);
5353
externvoidpq_init(void);
5454
externvoidpq_comm_reset(void);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp