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

Commit ee3a1a5

Browse files
committed
Remove check for accept() argument types
This check was used to accommodate a staggering variety in particular in the type of the third argument of accept(). This is no longer of concern on currently supported systems. We can just use socklen_t in the code and put in a simple check that substitutes int for socklen_t if it's missing, to cover the few stragglers. Reviewed-by: Andres Freund <andres@anarazel.de> Discussion: https://www.postgresql.org/message-id/3538f4c4-1886-64f2-dcff-aaad8267fb82@enterprisedb.com
1 parent 4cd046c commit ee3a1a5

File tree

13 files changed

+31
-178
lines changed

13 files changed

+31
-178
lines changed

aclocal.m4

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
dnl aclocal.m4
2-
m4_include([config/ac_func_accept_argtypes.m4])
32
m4_include([config/ax_prog_perl_modules.m4])
43
m4_include([config/ax_pthread.m4])
54
m4_include([config/c-compiler.m4])

config/ac_func_accept_argtypes.m4

-78
This file was deleted.

configure

+11-71
Original file line numberDiff line numberDiff line change
@@ -14615,6 +14615,17 @@ cat >>confdefs.h <<_ACEOF
1461514615
_ACEOF
1461614616

1461714617

14618+
fi
14619+
14620+
ac_fn_c_check_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" "#include <sys/socket.h>
14621+
"
14622+
if test "x$ac_cv_type_socklen_t" = xyes; then :
14623+
14624+
cat >>confdefs.h <<_ACEOF
14625+
#define HAVE_SOCKLEN_T 1
14626+
_ACEOF
14627+
14628+
1461814629
fi
1461914630

1462014631
ac_fn_c_check_type "$LINENO" "struct sockaddr_un" "ac_cv_type_struct_sockaddr_un" "#include <sys/types.h>
@@ -15327,77 +15338,6 @@ if test x"$pgac_cv_var_int_timezone" = xyes ; then
1532715338
$as_echo "#define HAVE_INT_TIMEZONE 1" >>confdefs.h
1532815339

1532915340
fi
15330-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking types of arguments for accept()" >&5
15331-
$as_echo_n "checking types of arguments for accept()... " >&6; }
15332-
if ${ac_cv_func_accept_return+:} false; then :
15333-
$as_echo_n "(cached) " >&6
15334-
else
15335-
if ${ac_cv_func_accept_arg1+:} false; then :
15336-
$as_echo_n "(cached) " >&6
15337-
else
15338-
if ${ac_cv_func_accept_arg2+:} false; then :
15339-
$as_echo_n "(cached) " >&6
15340-
else
15341-
if ${ac_cv_func_accept_arg3+:} false; then :
15342-
$as_echo_n "(cached) " >&6
15343-
else
15344-
for ac_cv_func_accept_return in 'int' 'SOCKET WSAAPI' 'unsigned int PASCAL'; do
15345-
for ac_cv_func_accept_arg1 in 'int' 'SOCKET' 'unsigned int'; do
15346-
for ac_cv_func_accept_arg2 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
15347-
for ac_cv_func_accept_arg3 in 'int' 'size_t' 'socklen_t' 'unsigned int' 'void'; do
15348-
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
15349-
/* end confdefs.h. */
15350-
#include <sys/types.h>
15351-
#include <sys/socket.h>
15352-
extern $ac_cv_func_accept_return accept ($ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2, $ac_cv_func_accept_arg3 *);
15353-
_ACEOF
15354-
if ac_fn_c_try_compile "$LINENO"; then :
15355-
ac_not_found=no; break 4
15356-
else
15357-
ac_not_found=yes
15358-
fi
15359-
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
15360-
done
15361-
done
15362-
done
15363-
done
15364-
if test "$ac_not_found" = yes; then
15365-
as_fn_error $? "could not determine argument types" "$LINENO" 5
15366-
fi
15367-
if test "$ac_cv_func_accept_arg3" = "void"; then
15368-
ac_cv_func_accept_arg3=int
15369-
fi
15370-
15371-
fi
15372-
15373-
fi
15374-
15375-
fi
15376-
15377-
fi
15378-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_accept_return, $ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2, $ac_cv_func_accept_arg3 *" >&5
15379-
$as_echo "$ac_cv_func_accept_return, $ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2, $ac_cv_func_accept_arg3 *" >&6; }
15380-
15381-
cat >>confdefs.h <<_ACEOF
15382-
#define ACCEPT_TYPE_RETURN $ac_cv_func_accept_return
15383-
_ACEOF
15384-
15385-
15386-
cat >>confdefs.h <<_ACEOF
15387-
#define ACCEPT_TYPE_ARG1 $ac_cv_func_accept_arg1
15388-
_ACEOF
15389-
15390-
15391-
cat >>confdefs.h <<_ACEOF
15392-
#define ACCEPT_TYPE_ARG2 $ac_cv_func_accept_arg2
15393-
_ACEOF
15394-
15395-
15396-
cat >>confdefs.h <<_ACEOF
15397-
#define ACCEPT_TYPE_ARG3 $ac_cv_func_accept_arg3
15398-
_ACEOF
15399-
15400-
1540115341
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether gettimeofday takes only one argument" >&5
1540215342
$as_echo_n "checking whether gettimeofday takes only one argument... " >&6; }
1540315343
if ${pgac_cv_func_gettimeofday_1arg+:} false; then :

configure.ac

+1-1
Original file line numberDiff line numberDiff line change
@@ -1552,6 +1552,7 @@ PGAC_C_BUILTIN_UNREACHABLE
15521552
PGAC_C_COMPUTED_GOTO
15531553
PGAC_STRUCT_TIMEZONE
15541554
PGAC_UNION_SEMUN
1555+
AC_CHECK_TYPES(socklen_t, [], [], [#include <sys/socket.h>])
15551556
PGAC_STRUCT_SOCKADDR_UN
15561557
PGAC_STRUCT_SOCKADDR_STORAGE
15571558
PGAC_STRUCT_SOCKADDR_STORAGE_MEMBERS
@@ -1686,7 +1687,6 @@ fi
16861687
##
16871688

16881689
PGAC_VAR_INT_TIMEZONE
1689-
AC_FUNC_ACCEPT_ARGTYPES
16901690
PGAC_FUNC_GETTIMEOFDAY_1ARG
16911691
PGAC_FUNC_WCSTOMBS_L
16921692

src/backend/libpq/auth.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3026,7 +3026,7 @@ PerformRadiusTransaction(const char *server, const char *secret, const char *por
30263026
struct addrinfo hint;
30273027
struct addrinfo *serveraddrs;
30283028
int port;
3029-
ACCEPT_TYPE_ARG3 addrsize;
3029+
socklen_t addrsize;
30303030
fd_set fdset;
30313031
struct timeval endtime;
30323032
int i,

src/backend/libpq/pqcomm.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -1632,7 +1632,7 @@ pq_getkeepalivesidle(Port *port)
16321632
if (port->default_keepalives_idle == 0)
16331633
{
16341634
#ifndef WIN32
1635-
ACCEPT_TYPE_ARG3 size = sizeof(port->default_keepalives_idle);
1635+
socklen_t size = sizeof(port->default_keepalives_idle);
16361636

16371637
if (getsockopt(port->sock, IPPROTO_TCP, PG_TCP_KEEPALIVE_IDLE,
16381638
(char *) &port->default_keepalives_idle,
@@ -1717,7 +1717,7 @@ pq_getkeepalivesinterval(Port *port)
17171717
if (port->default_keepalives_interval == 0)
17181718
{
17191719
#ifndef WIN32
1720-
ACCEPT_TYPE_ARG3 size = sizeof(port->default_keepalives_interval);
1720+
socklen_t size = sizeof(port->default_keepalives_interval);
17211721

17221722
if (getsockopt(port->sock, IPPROTO_TCP, TCP_KEEPINTVL,
17231723
(char *) &port->default_keepalives_interval,
@@ -1800,7 +1800,7 @@ pq_getkeepalivescount(Port *port)
18001800

18011801
if (port->default_keepalives_count == 0)
18021802
{
1803-
ACCEPT_TYPE_ARG3 size = sizeof(port->default_keepalives_count);
1803+
socklen_t size = sizeof(port->default_keepalives_count);
18041804

18051805
if (getsockopt(port->sock, IPPROTO_TCP, TCP_KEEPCNT,
18061806
(char *) &port->default_keepalives_count,
@@ -1875,7 +1875,7 @@ pq_gettcpusertimeout(Port *port)
18751875

18761876
if (port->default_tcp_user_timeout == 0)
18771877
{
1878-
ACCEPT_TYPE_ARG3 size = sizeof(port->default_tcp_user_timeout);
1878+
socklen_t size = sizeof(port->default_tcp_user_timeout);
18791879

18801880
if (getsockopt(port->sock, IPPROTO_TCP, TCP_USER_TIMEOUT,
18811881
(char *) &port->default_tcp_user_timeout,

src/backend/postmaster/pgstat.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ static void pgstat_recv_tempfile(PgStat_MsgTempFile *msg, int len);
391391
void
392392
pgstat_init(void)
393393
{
394-
ACCEPT_TYPE_ARG3 alen;
394+
socklen_t alen;
395395
struct addrinfo *addrs = NULL,
396396
*addr,
397397
hints;
@@ -624,7 +624,7 @@ pgstat_init(void)
624624
{
625625
int old_rcvbuf;
626626
int new_rcvbuf;
627-
ACCEPT_TYPE_ARG3 rcvbufsize = sizeof(old_rcvbuf);
627+
socklen_t rcvbufsize = sizeof(old_rcvbuf);
628628

629629
if (getsockopt(pgStatSock, SOL_SOCKET, SO_RCVBUF,
630630
(char *) &old_rcvbuf, &rcvbufsize) < 0)

src/include/libpq/pqcomm.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ struct sockaddr_storage
6262
typedef struct
6363
{
6464
struct sockaddr_storage addr;
65-
ACCEPT_TYPE_ARG3 salen;
65+
socklen_t salen;
6666
} SockAddr;
6767

6868
/* Configure the UNIX socket location for the well known port. */

src/include/pg_config.h.in

+3-12
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
/* src/include/pg_config.h.in. Generated from configure.ac by autoheader. */
22

3-
/* Define to the type of arg 1 of 'accept' */
4-
#undef ACCEPT_TYPE_ARG1
5-
6-
/* Define to the type of arg 2 of 'accept' */
7-
#undef ACCEPT_TYPE_ARG2
8-
9-
/* Define to the type of arg 3 of 'accept' */
10-
#undef ACCEPT_TYPE_ARG3
11-
12-
/* Define to the return type of 'accept' */
13-
#undef ACCEPT_TYPE_RETURN
14-
153
/* Define if building universal (internal helper macro) */
164
#undef AC_APPLE_UNIVERSAL_BUILD
175

@@ -518,6 +506,9 @@
518506
/* Define to 1 if you have the `shm_open' function. */
519507
#undef HAVE_SHM_OPEN
520508

509+
/* Define to 1 if the system has the type `socklen_t'. */
510+
#undef HAVE_SOCKLEN_T
511+
521512
/* Define to 1 if you have spinlocks. */
522513
#undef HAVE_SPINLOCKS
523514

src/include/port.h

+4
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ typedef SOCKET pgsocket;
3737
#define PGINVALID_SOCKET INVALID_SOCKET
3838
#endif
3939

40+
#ifndef HAVE_SOCKLEN_T
41+
typedef int socklen_t;
42+
#endif
43+
4044
/* non-blocking */
4145
extern bool pg_set_noblock(pgsocket sock);
4246
extern bool pg_set_block(pgsocket sock);

src/interfaces/libpq/fe-connect.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2744,7 +2744,7 @@ PQconnectPoll(PGconn *conn)
27442744

27452745
case CONNECTION_STARTED:
27462746
{
2747-
ACCEPT_TYPE_ARG3 optlen = sizeof(optval);
2747+
socklen_t optlen = sizeof(optval);
27482748

27492749
/*
27502750
* Write ready, since we've made it here, so the connection

src/port/getpeereid.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ getpeereid(int sock, uid_t *uid, gid_t *gid)
3737
#if defined(SO_PEERCRED)
3838
/* Linux: use getsockopt(SO_PEERCRED) */
3939
struct ucred peercred;
40-
ACCEPT_TYPE_ARG3 so_len = sizeof(peercred);
40+
socklen_t so_len = sizeof(peercred);
4141

4242
if (getsockopt(sock, SOL_SOCKET, SO_PEERCRED, &peercred, &so_len) != 0 ||
4343
so_len != sizeof(peercred))
@@ -48,7 +48,7 @@ getpeereid(int sock, uid_t *uid, gid_t *gid)
4848
#elif defined(LOCAL_PEERCRED)
4949
/* Debian with FreeBSD kernel: use getsockopt(LOCAL_PEERCRED) */
5050
struct xucred peercred;
51-
ACCEPT_TYPE_ARG3 so_len = sizeof(peercred);
51+
socklen_t so_len = sizeof(peercred);
5252

5353
if (getsockopt(sock, 0, LOCAL_PEERCRED, &peercred, &so_len) != 0 ||
5454
so_len != sizeof(peercred) ||

src/tools/msvc/Solution.pm

+1-4
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,6 @@ sub GenerateFiles
205205
# Every symbol in pg_config.h.in must be accounted for here. Set
206206
# to undef if the symbol should not be defined.
207207
my %define = (
208-
ACCEPT_TYPE_ARG1 => 'unsigned int',
209-
ACCEPT_TYPE_ARG2 => 'struct sockaddr *',
210-
ACCEPT_TYPE_ARG3 => 'int',
211-
ACCEPT_TYPE_RETURN => 'unsigned int PASCAL',
212208
ALIGNOF_DOUBLE => 8,
213209
ALIGNOF_INT => 4,
214210
ALIGNOF_LONG => 4,
@@ -365,6 +361,7 @@ sub GenerateFiles
365361
HAVE_SETPROCTITLE_FAST => undef,
366362
HAVE_SETSID => undef,
367363
HAVE_SHM_OPEN => undef,
364+
HAVE_SOCKLEN_T => 1,
368365
HAVE_SPINLOCKS => 1,
369366
HAVE_SRANDOM => undef,
370367
HAVE_STDBOOL_H => 1,

0 commit comments

Comments
 (0)