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

Commit797129e

Browse files
committed
Remove IS_AF_UNIX macro
The AF_UNIX macro was being used unprotected by HAVE_UNIX_SOCKETS,apparently since 2008. So the redirection through IS_AF_UNIX() isapparently no longer necessary. (More generally, all supportedplatforms are now HAVE_UNIX_SOCKETS, but even if there were a newplatform in the future, it seems plausible that it would define theAF_UNIX symbol even without kernel support.) So remove theIS_AF_UNIX() macro and make the code a bit more consistent.Discussion:https://www.postgresql.org/message-id/flat/f2d26815-9832-e333-d52d-72fbc0ade896%40enterprisedb.com
1 parenta59135a commit797129e

File tree

5 files changed

+23
-29
lines changed

5 files changed

+23
-29
lines changed

‎src/backend/libpq/hba.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,12 +2138,12 @@ check_hba(hbaPort *port)
21382138
/* Check connection type */
21392139
if (hba->conntype==ctLocal)
21402140
{
2141-
if (!IS_AF_UNIX(port->raddr.addr.ss_family))
2141+
if (port->raddr.addr.ss_family!=AF_UNIX)
21422142
continue;
21432143
}
21442144
else
21452145
{
2146-
if (IS_AF_UNIX(port->raddr.addr.ss_family))
2146+
if (port->raddr.addr.ss_family==AF_UNIX)
21472147
continue;
21482148

21492149
/* Check SSL state */

‎src/backend/libpq/pqcomm.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ StreamServerPort(int family, const char *hostName, unsigned short portNumber,
409409

410410
for (addr=addrs;addr;addr=addr->ai_next)
411411
{
412-
if (!IS_AF_UNIX(family)&&IS_AF_UNIX(addr->ai_family))
412+
if (family!=AF_UNIX&&addr->ai_family==AF_UNIX)
413413
{
414414
/*
415415
* Only set up a unix domain socket when they really asked for it.
@@ -494,7 +494,7 @@ StreamServerPort(int family, const char *hostName, unsigned short portNumber,
494494
* unpredictable behavior. With no flags at all, win32 behaves as Unix
495495
* with SO_REUSEADDR.
496496
*/
497-
if (!IS_AF_UNIX(addr->ai_family))
497+
if (addr->ai_family!=AF_UNIX)
498498
{
499499
if ((setsockopt(fd,SOL_SOCKET,SO_REUSEADDR,
500500
(char*)&one,sizeof(one)))==-1)
@@ -546,7 +546,7 @@ StreamServerPort(int family, const char *hostName, unsigned short portNumber,
546546
errmsg("could not bind %s address \"%s\": %m",
547547
familyDesc,addrDesc),
548548
saved_errno==EADDRINUSE ?
549-
(IS_AF_UNIX(addr->ai_family) ?
549+
(addr->ai_family==AF_UNIX ?
550550
errhint("Is another postmaster already running on port %d?",
551551
(int)portNumber) :
552552
errhint("Is another postmaster already running on port %d?"
@@ -764,7 +764,7 @@ StreamConnection(pgsocket server_fd, Port *port)
764764
}
765765

766766
/* select NODELAY and KEEPALIVE options if it's a TCP connection */
767-
if (!IS_AF_UNIX(port->laddr.addr.ss_family))
767+
if (port->laddr.addr.ss_family!=AF_UNIX)
768768
{
769769
inton;
770770
#ifdefWIN32
@@ -1639,7 +1639,7 @@ int
16391639
pq_getkeepalivesidle(Port*port)
16401640
{
16411641
#if defined(PG_TCP_KEEPALIVE_IDLE)|| defined(SIO_KEEPALIVE_VALS)
1642-
if (port==NULL||IS_AF_UNIX(port->laddr.addr.ss_family))
1642+
if (port==NULL||port->laddr.addr.ss_family==AF_UNIX)
16431643
return0;
16441644

16451645
if (port->keepalives_idle!=0)
@@ -1673,7 +1673,7 @@ pq_getkeepalivesidle(Port *port)
16731673
int
16741674
pq_setkeepalivesidle(intidle,Port*port)
16751675
{
1676-
if (port==NULL||IS_AF_UNIX(port->laddr.addr.ss_family))
1676+
if (port==NULL||port->laddr.addr.ss_family==AF_UNIX)
16771677
returnSTATUS_OK;
16781678

16791679
/* check SIO_KEEPALIVE_VALS here, not just WIN32, as some toolchains lack it */
@@ -1724,7 +1724,7 @@ int
17241724
pq_getkeepalivesinterval(Port*port)
17251725
{
17261726
#if defined(TCP_KEEPINTVL)|| defined(SIO_KEEPALIVE_VALS)
1727-
if (port==NULL||IS_AF_UNIX(port->laddr.addr.ss_family))
1727+
if (port==NULL||port->laddr.addr.ss_family==AF_UNIX)
17281728
return0;
17291729

17301730
if (port->keepalives_interval!=0)
@@ -1758,7 +1758,7 @@ pq_getkeepalivesinterval(Port *port)
17581758
int
17591759
pq_setkeepalivesinterval(intinterval,Port*port)
17601760
{
1761-
if (port==NULL||IS_AF_UNIX(port->laddr.addr.ss_family))
1761+
if (port==NULL||port->laddr.addr.ss_family==AF_UNIX)
17621762
returnSTATUS_OK;
17631763

17641764
#if defined(TCP_KEEPINTVL)|| defined(SIO_KEEPALIVE_VALS)
@@ -1808,7 +1808,7 @@ int
18081808
pq_getkeepalivescount(Port*port)
18091809
{
18101810
#ifdefTCP_KEEPCNT
1811-
if (port==NULL||IS_AF_UNIX(port->laddr.addr.ss_family))
1811+
if (port==NULL||port->laddr.addr.ss_family==AF_UNIX)
18121812
return0;
18131813

18141814
if (port->keepalives_count!=0)
@@ -1837,7 +1837,7 @@ pq_getkeepalivescount(Port *port)
18371837
int
18381838
pq_setkeepalivescount(intcount,Port*port)
18391839
{
1840-
if (port==NULL||IS_AF_UNIX(port->laddr.addr.ss_family))
1840+
if (port==NULL||port->laddr.addr.ss_family==AF_UNIX)
18411841
returnSTATUS_OK;
18421842

18431843
#ifdefTCP_KEEPCNT
@@ -1883,7 +1883,7 @@ int
18831883
pq_gettcpusertimeout(Port*port)
18841884
{
18851885
#ifdefTCP_USER_TIMEOUT
1886-
if (port==NULL||IS_AF_UNIX(port->laddr.addr.ss_family))
1886+
if (port==NULL||port->laddr.addr.ss_family==AF_UNIX)
18871887
return0;
18881888

18891889
if (port->tcp_user_timeout!=0)
@@ -1912,7 +1912,7 @@ pq_gettcpusertimeout(Port *port)
19121912
int
19131913
pq_settcpusertimeout(inttimeout,Port*port)
19141914
{
1915-
if (port==NULL||IS_AF_UNIX(port->laddr.addr.ss_family))
1915+
if (port==NULL||port->laddr.addr.ss_family==AF_UNIX)
19161916
returnSTATUS_OK;
19171917

19181918
#ifdefTCP_USER_TIMEOUT

‎src/backend/postmaster/postmaster.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2085,7 +2085,7 @@ ProcessStartupPacket(Port *port, bool ssl_done, bool gss_done)
20852085

20862086
#ifdefUSE_SSL
20872087
/* No SSL when disabled or on Unix sockets */
2088-
if (!LoadedSSL||IS_AF_UNIX(port->laddr.addr.ss_family))
2088+
if (!LoadedSSL||port->laddr.addr.ss_family==AF_UNIX)
20892089
SSLok='N';
20902090
else
20912091
SSLok='S';/* Support for SSL */
@@ -2134,7 +2134,7 @@ ProcessStartupPacket(Port *port, bool ssl_done, bool gss_done)
21342134

21352135
#ifdefENABLE_GSS
21362136
/* No GSSAPI encryption when on Unix socket */
2137-
if (!IS_AF_UNIX(port->laddr.addr.ss_family))
2137+
if (port->laddr.addr.ss_family!=AF_UNIX)
21382138
GSSok='G';
21392139
#endif
21402140

‎src/include/common/ip.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@
1818
#include"libpq/pqcomm.h"/* pgrminclude ignore */
1919

2020

21-
#ifdefHAVE_UNIX_SOCKETS
22-
#defineIS_AF_UNIX(fam) ((fam) == AF_UNIX)
23-
#else
24-
#defineIS_AF_UNIX(fam) (0)
25-
#endif
26-
2721
externintpg_getaddrinfo_all(constchar*hostname,constchar*servname,
2822
conststructaddrinfo*hintp,
2923
structaddrinfo**result);

‎src/interfaces/libpq/fe-connect.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,7 +1694,7 @@ static void
16941694
emitHostIdentityInfo(PGconn*conn,constchar*host_addr)
16951695
{
16961696
#ifdefHAVE_UNIX_SOCKETS
1697-
if (IS_AF_UNIX(conn->raddr.addr.ss_family))
1697+
if (conn->raddr.addr.ss_family==AF_UNIX)
16981698
{
16991699
charservice[NI_MAXHOST];
17001700

@@ -1758,7 +1758,7 @@ connectFailureMessage(PGconn *conn, int errorno)
17581758
SOCK_STRERROR(errorno,sebuf,sizeof(sebuf)));
17591759

17601760
#ifdefHAVE_UNIX_SOCKETS
1761-
if (IS_AF_UNIX(conn->raddr.addr.ss_family))
1761+
if (conn->raddr.addr.ss_family==AF_UNIX)
17621762
appendPQExpBufferStr(&conn->errorMessage,
17631763
libpq_gettext("\tIs the server running locally and accepting connections on that socket?\n"));
17641764
else
@@ -2590,7 +2590,7 @@ PQconnectPoll(PGconn *conn)
25902590
* TCP sockets, nonblock mode, close-on-exec. Try the
25912591
* next address if any of this fails.
25922592
*/
2593-
if (!IS_AF_UNIX(addr_cur->ai_family))
2593+
if (addr_cur->ai_family!=AF_UNIX)
25942594
{
25952595
if (!connectNoDelay(conn))
25962596
{
@@ -2619,7 +2619,7 @@ PQconnectPoll(PGconn *conn)
26192619
}
26202620
#endif/* F_SETFD */
26212621

2622-
if (!IS_AF_UNIX(addr_cur->ai_family))
2622+
if (addr_cur->ai_family!=AF_UNIX)
26232623
{
26242624
#ifndefWIN32
26252625
inton=1;
@@ -2821,7 +2821,7 @@ PQconnectPoll(PGconn *conn)
28212821
* Unix-domain socket.
28222822
*/
28232823
if (conn->requirepeer&&conn->requirepeer[0]&&
2824-
IS_AF_UNIX(conn->raddr.addr.ss_family))
2824+
conn->raddr.addr.ss_family==AF_UNIX)
28252825
{
28262826
#ifndefWIN32
28272827
char*remote_username;
@@ -2867,7 +2867,7 @@ PQconnectPoll(PGconn *conn)
28672867
#endif/* WIN32 */
28682868
}
28692869

2870-
if (IS_AF_UNIX(conn->raddr.addr.ss_family))
2870+
if (conn->raddr.addr.ss_family==AF_UNIX)
28712871
{
28722872
/* Don't request SSL or GSSAPI over Unix sockets */
28732873
#ifdefUSE_SSL
@@ -4528,7 +4528,7 @@ PQcancel(PGcancel *cancel, char *errbuf, int errbufsize)
45284528
* This ensures that this function does not block indefinitely when
45294529
* reasonable keepalive and timeout settings have been provided.
45304530
*/
4531-
if (!IS_AF_UNIX(cancel->raddr.addr.ss_family)&&
4531+
if (cancel->raddr.addr.ss_family!=AF_UNIX&&
45324532
cancel->keepalives!=0)
45334533
{
45344534
#ifndefWIN32

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp