Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5579388

Browse files
committed
Remove replacement code for getaddrinfo.
SUSv3, all targeted Unixes and modern Windows have getaddrinfo() and related interfaces. Drop the replacement implementation, and adjust some headers slightly to make sure that the APIs are visible everywhere using standard POSIX headers and names. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/CA%2BhUKG%2BL_3brvh%3D8e0BW_VfX9h7MtwgN%3DnFHP5o7X2oZucY9dg%40mail.gmail.com
1 parent de42bc3 commit 5579388

File tree

18 files changed

+22
-690
lines changed

18 files changed

+22
-690
lines changed

config/c-library.m4

-11
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,6 @@ AC_DEFUN([PGAC_STRUCT_SOCKADDR_STORAGE_MEMBERS],
8989
])])# PGAC_STRUCT_SOCKADDR_STORAGE_MEMBERS
9090

9191

92-
# PGAC_STRUCT_ADDRINFO
93-
# -----------------------
94-
# If `struct addrinfo' exists, define HAVE_STRUCT_ADDRINFO.
95-
AC_DEFUN([PGAC_STRUCT_ADDRINFO],
96-
[AC_CHECK_TYPES([struct addrinfo], [], [],
97-
[#include <sys/types.h>
98-
#include <sys/socket.h>
99-
#include <netdb.h>
100-
])])# PGAC_STRUCT_ADDRINFO
101-
102-
10392
# PGAC_TYPE_LOCALE_T
10493
# ------------------
10594
# Check for the locale_t type and find the right header file. macOS

configure

-42
Original file line numberDiff line numberDiff line change
@@ -15119,20 +15119,6 @@ cat >>confdefs.h <<_ACEOF
1511915119
_ACEOF
1512015120

1512115121

15122-
fi
15123-
15124-
ac_fn_c_check_type "$LINENO" "struct addrinfo" "ac_cv_type_struct_addrinfo" "#include <sys/types.h>
15125-
#include <sys/socket.h>
15126-
#include <netdb.h>
15127-
15128-
"
15129-
if test "x$ac_cv_type_struct_addrinfo" = xyes; then :
15130-
15131-
cat >>confdefs.h <<_ACEOF
15132-
#define HAVE_STRUCT_ADDRINFO 1
15133-
_ACEOF
15134-
15135-
1513615122
fi
1513715123

1513815124

@@ -16533,34 +16519,6 @@ esac
1653316519
$as_echo "$as_me: On $host_os we will use our strtof wrapper." >&6;}
1653416520
fi
1653516521

16536-
# System's version of getaddrinfo(), if any, may be used only if we found
16537-
# a definition for struct addrinfo; see notes in src/include/getaddrinfo.h.
16538-
# We use only our own getaddrinfo.c on Windows, but it's time to revisit that.
16539-
if test x"$ac_cv_type_struct_addrinfo" = xyes && \
16540-
test "$PORTNAME" != "win32"; then
16541-
ac_fn_c_check_func "$LINENO" "getaddrinfo" "ac_cv_func_getaddrinfo"
16542-
if test "x$ac_cv_func_getaddrinfo" = xyes; then :
16543-
$as_echo "#define HAVE_GETADDRINFO 1" >>confdefs.h
16544-
16545-
else
16546-
case " $LIBOBJS " in
16547-
*" getaddrinfo.$ac_objext "* ) ;;
16548-
*) LIBOBJS="$LIBOBJS getaddrinfo.$ac_objext"
16549-
;;
16550-
esac
16551-
16552-
fi
16553-
16554-
16555-
else
16556-
case " $LIBOBJS " in
16557-
*" getaddrinfo.$ac_objext "* ) ;;
16558-
*) LIBOBJS="$LIBOBJS getaddrinfo.$ac_objext"
16559-
;;
16560-
esac
16561-
16562-
fi
16563-
1656416522
# Similarly, use system's getopt_long() only if system provides struct option.
1656516523
if test x"$ac_cv_type_struct_option" = xyes ; then
1656616524
ac_fn_c_check_func "$LINENO" "getopt_long" "ac_cv_func_getopt_long"

configure.ac

-11
Original file line numberDiff line numberDiff line change
@@ -1619,7 +1619,6 @@ PGAC_STRUCT_TIMEZONE
16191619
PGAC_UNION_SEMUN
16201620
AC_CHECK_TYPES(socklen_t, [], [], [#include <sys/socket.h>])
16211621
PGAC_STRUCT_SOCKADDR_STORAGE_MEMBERS
1622-
PGAC_STRUCT_ADDRINFO
16231622

16241623
PGAC_TYPE_LOCALE_T
16251624

@@ -1849,16 +1848,6 @@ if test "$PORTNAME" = "win32" -o "$PORTNAME" = "cygwin"; then
18491848
AC_MSG_NOTICE([On $host_os we will use our strtof wrapper.])
18501849
fi
18511850

1852-
# System's version of getaddrinfo(), if any, may be used only if we found
1853-
# a definition for struct addrinfo; see notes in src/include/getaddrinfo.h.
1854-
# We use only our own getaddrinfo.c on Windows, but it's time to revisit that.
1855-
if test x"$ac_cv_type_struct_addrinfo" = xyes && \
1856-
test "$PORTNAME" != "win32"; then
1857-
AC_REPLACE_FUNCS([getaddrinfo])
1858-
else
1859-
AC_LIBOBJ(getaddrinfo)
1860-
fi
1861-
18621851
# Similarly, use system's getopt_long() only if system provides struct option.
18631852
if test x"$ac_cv_type_struct_option" = xyes ; then
18641853
AC_REPLACE_FUNCS([getopt_long])

src/backend/libpq/auth.c

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <sys/select.h>
2020
#include <sys/socket.h>
2121
#include <netinet/in.h>
22+
#include <netdb.h>
2223
#include <pwd.h>
2324
#include <unistd.h>
2425

src/backend/libpq/hba.c

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <fcntl.h>
2222
#include <sys/param.h>
2323
#include <sys/socket.h>
24+
#include <netdb.h>
2425
#include <netinet/in.h>
2526
#include <arpa/inet.h>
2627
#include <unistd.h>

src/bin/initdb/initdb.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050

5151
#include <dirent.h>
5252
#include <fcntl.h>
53+
#include <netdb.h>
54+
#include <sys/socket.h>
5355
#include <sys/stat.h>
5456
#include <unistd.h>
5557
#include <signal.h>
@@ -72,7 +74,6 @@
7274
#include "common/string.h"
7375
#include "common/username.h"
7476
#include "fe_utils/string_utils.h"
75-
#include "getaddrinfo.h"
7677
#include "getopt_long.h"
7778
#include "mb/pg_wchar.h"
7879
#include "miscadmin.h"

src/include/common/ip.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
#ifndef IP_H
1515
#define IP_H
1616

17-
#include "getaddrinfo.h" /* pgrminclude ignore */
17+
#include <netdb.h>
18+
#include <sys/socket.h>
19+
1820
#include "libpq/pqcomm.h" /* pgrminclude ignore */
1921

2022

src/include/getaddrinfo.h

-162
This file was deleted.

src/include/libpq/libpq-be.h

-8
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,6 @@
3333
#else
3434
#include <gssapi/gssapi.h>
3535
#endif /* HAVE_GSSAPI_H */
36-
/*
37-
* GSSAPI brings in headers that set a lot of things in the global namespace on win32,
38-
* that doesn't match the msvc build. It gives a bunch of compiler warnings that we ignore,
39-
* but also defines a symbol that simply does not exist. Undefine it again.
40-
*/
41-
#ifdef _MSC_VER
42-
#undef HAVE_GETADDRINFO
43-
#endif
4436
#endif /* ENABLE_GSS */
4537

4638
#ifdef ENABLE_SSPI

src/include/pg_config.h.in

-6
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,6 @@
178178
*/
179179
#undef HAVE_GCC__SYNC_INT64_CAS
180180

181-
/* Define to 1 if you have the `getaddrinfo' function. */
182-
#undef HAVE_GETADDRINFO
183-
184181
/* Define to 1 if you have the `gethostbyname_r' function. */
185182
#undef HAVE_GETHOSTBYNAME_R
186183

@@ -448,9 +445,6 @@
448445
/* Define to 1 if you have the `strsignal' function. */
449446
#undef HAVE_STRSIGNAL
450447

451-
/* Define to 1 if the system has the type `struct addrinfo'. */
452-
#undef HAVE_STRUCT_ADDRINFO
453-
454448
/* Define to 1 if the system has the type `struct cmsgcred'. */
455449
#undef HAVE_STRUCT_CMSGCRED
456450

src/include/port/win32/netdb.h

+8
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
11
/* src/include/port/win32/netdb.h */
2+
#ifndef WIN32_NETDB_H
3+
#define WIN32_NETDB_H
4+
5+
#include <ws2tcpip.h>
6+
7+
#define gai_strerror gai_strerrorA
8+
9+
#endif

src/include/replication/walreceiver.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
#ifndef _WALRECEIVER_H
1313
#define _WALRECEIVER_H
1414

15+
#include <netdb.h>
16+
#include <sys/socket.h>
17+
1518
#include "access/xlog.h"
1619
#include "access/xlogdefs.h"
17-
#include "getaddrinfo.h" /* for NI_MAXHOST */
1820
#include "pgtime.h"
1921
#include "port/atomics.h"
2022
#include "replication/logicalproto.h"

src/interfaces/libpq/fe-connect.c

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <sys/stat.h>
1919
#include <fcntl.h>
2020
#include <ctype.h>
21+
#include <netdb.h>
2122
#include <time.h>
2223
#include <unistd.h>
2324

src/interfaces/libpq/libpq-int.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
/* We assume libpq-fe.h has already been included. */
2424
#include "libpq-events.h"
2525

26+
#include <netdb.h>
27+
#include <sys/socket.h>
2628
#include <time.h>
2729
#ifndef WIN32
2830
#include <sys/time.h>
@@ -38,7 +40,6 @@
3840
#endif
3941

4042
/* include stuff common to fe and be */
41-
#include "getaddrinfo.h"
4243
#include "libpq/pqcomm.h"
4344
/* include stuff found in fe only */
4445
#include "fe-auth-sasl.h"

src/port/Makefile

-4
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,6 @@ libpgport.a: $(OBJS)
8484
rm -f $@
8585
$(AR) $(AROPT) $@ $^
8686

87-
# getaddrinfo.o and getaddrinfo_shlib.o need PTHREAD_CFLAGS (but getaddrinfo_srv.o does not)
88-
getaddrinfo.o: CFLAGS+=$(PTHREAD_CFLAGS)
89-
getaddrinfo_shlib.o: CFLAGS+=$(PTHREAD_CFLAGS)
90-
9187
# thread.o and thread_shlib.o need PTHREAD_CFLAGS (but thread_srv.o does not)
9288
thread.o: CFLAGS+=$(PTHREAD_CFLAGS)
9389
thread_shlib.o: CFLAGS+=$(PTHREAD_CFLAGS)

0 commit comments

Comments
 (0)