diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2021-11-09 15:20:47 +0100 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2021-11-09 15:35:26 +0100 |
commit | ee3a1a5b636b69dde33d68c428dd56b3389a4538 (patch) | |
tree | 6943325f2baa9e3e70994b3edd79ea5534ed6ba7 /src | |
parent | 4cd046c203bbca2955182f78eabc06e831ffdbb1 (diff) | |
download | postgresql-ee3a1a5b636b69dde33d68c428dd56b3389a4538.tar.gz postgresql-ee3a1a5b636b69dde33d68c428dd56b3389a4538.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/libpq/auth.c | 2 | ||||
-rw-r--r-- | src/backend/libpq/pqcomm.c | 8 | ||||
-rw-r--r-- | src/backend/postmaster/pgstat.c | 4 | ||||
-rw-r--r-- | src/include/libpq/pqcomm.h | 2 | ||||
-rw-r--r-- | src/include/pg_config.h.in | 15 | ||||
-rw-r--r-- | src/include/port.h | 4 | ||||
-rw-r--r-- | src/interfaces/libpq/fe-connect.c | 2 | ||||
-rw-r--r-- | src/port/getpeereid.c | 4 | ||||
-rw-r--r-- | src/tools/msvc/Solution.pm | 5 |
9 files changed, 19 insertions, 27 deletions
diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c index a317aef1c92..7bcf52523b4 100644 --- a/src/backend/libpq/auth.c +++ b/src/backend/libpq/auth.c @@ -3026,7 +3026,7 @@ PerformRadiusTransaction(const char *server, const char *secret, const char *por struct addrinfo hint; struct addrinfo *serveraddrs; int port; - ACCEPT_TYPE_ARG3 addrsize; + socklen_t addrsize; fd_set fdset; struct timeval endtime; int i, diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c index 44782f2d88d..9ebba025cc7 100644 --- a/src/backend/libpq/pqcomm.c +++ b/src/backend/libpq/pqcomm.c @@ -1632,7 +1632,7 @@ pq_getkeepalivesidle(Port *port) if (port->default_keepalives_idle == 0) { #ifndef WIN32 - ACCEPT_TYPE_ARG3 size = sizeof(port->default_keepalives_idle); + socklen_t size = sizeof(port->default_keepalives_idle); if (getsockopt(port->sock, IPPROTO_TCP, PG_TCP_KEEPALIVE_IDLE, (char *) &port->default_keepalives_idle, @@ -1717,7 +1717,7 @@ pq_getkeepalivesinterval(Port *port) if (port->default_keepalives_interval == 0) { #ifndef WIN32 - ACCEPT_TYPE_ARG3 size = sizeof(port->default_keepalives_interval); + socklen_t size = sizeof(port->default_keepalives_interval); if (getsockopt(port->sock, IPPROTO_TCP, TCP_KEEPINTVL, (char *) &port->default_keepalives_interval, @@ -1800,7 +1800,7 @@ pq_getkeepalivescount(Port *port) if (port->default_keepalives_count == 0) { - ACCEPT_TYPE_ARG3 size = sizeof(port->default_keepalives_count); + socklen_t size = sizeof(port->default_keepalives_count); if (getsockopt(port->sock, IPPROTO_TCP, TCP_KEEPCNT, (char *) &port->default_keepalives_count, @@ -1875,7 +1875,7 @@ pq_gettcpusertimeout(Port *port) if (port->default_tcp_user_timeout == 0) { - ACCEPT_TYPE_ARG3 size = sizeof(port->default_tcp_user_timeout); + socklen_t size = sizeof(port->default_tcp_user_timeout); if (getsockopt(port->sock, IPPROTO_TCP, TCP_USER_TIMEOUT, (char *) &port->default_tcp_user_timeout, diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c index b7d0fbaefdd..8c166e5e161 100644 --- a/src/backend/postmaster/pgstat.c +++ b/src/backend/postmaster/pgstat.c @@ -391,7 +391,7 @@ static void pgstat_recv_tempfile(PgStat_MsgTempFile *msg, int len); void pgstat_init(void) { - ACCEPT_TYPE_ARG3 alen; + socklen_t alen; struct addrinfo *addrs = NULL, *addr, hints; @@ -624,7 +624,7 @@ retry2: { int old_rcvbuf; int new_rcvbuf; - ACCEPT_TYPE_ARG3 rcvbufsize = sizeof(old_rcvbuf); + socklen_t rcvbufsize = sizeof(old_rcvbuf); if (getsockopt(pgStatSock, SOL_SOCKET, SO_RCVBUF, (char *) &old_rcvbuf, &rcvbufsize) < 0) diff --git a/src/include/libpq/pqcomm.h b/src/include/libpq/pqcomm.h index be9d9705744..1bcc189deeb 100644 --- a/src/include/libpq/pqcomm.h +++ b/src/include/libpq/pqcomm.h @@ -62,7 +62,7 @@ struct sockaddr_storage typedef struct { struct sockaddr_storage addr; - ACCEPT_TYPE_ARG3 salen; + socklen_t salen; } SockAddr; /* Configure the UNIX socket location for the well known port. */ diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in index 15ffdd895aa..ca3592465ed 100644 --- a/src/include/pg_config.h.in +++ b/src/include/pg_config.h.in @@ -1,17 +1,5 @@ /* src/include/pg_config.h.in. Generated from configure.ac by autoheader. */ -/* Define to the type of arg 1 of 'accept' */ -#undef ACCEPT_TYPE_ARG1 - -/* Define to the type of arg 2 of 'accept' */ -#undef ACCEPT_TYPE_ARG2 - -/* Define to the type of arg 3 of 'accept' */ -#undef ACCEPT_TYPE_ARG3 - -/* Define to the return type of 'accept' */ -#undef ACCEPT_TYPE_RETURN - /* Define if building universal (internal helper macro) */ #undef AC_APPLE_UNIVERSAL_BUILD @@ -518,6 +506,9 @@ /* Define to 1 if you have the `shm_open' function. */ #undef HAVE_SHM_OPEN +/* Define to 1 if the system has the type `socklen_t'. */ +#undef HAVE_SOCKLEN_T + /* Define to 1 if you have spinlocks. */ #undef HAVE_SPINLOCKS diff --git a/src/include/port.h b/src/include/port.h index 2ff529fa59b..ae68d9c3c79 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -37,6 +37,10 @@ typedef SOCKET pgsocket; #define PGINVALID_SOCKET INVALID_SOCKET #endif +#ifndef HAVE_SOCKLEN_T +typedef int socklen_t; +#endif + /* non-blocking */ extern bool pg_set_noblock(pgsocket sock); extern bool pg_set_block(pgsocket sock); diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index f0fdd294a40..9b6a6939f07 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -2744,7 +2744,7 @@ keep_going: /* We will come back to here until there is case CONNECTION_STARTED: { - ACCEPT_TYPE_ARG3 optlen = sizeof(optval); + socklen_t optlen = sizeof(optval); /* * Write ready, since we've made it here, so the connection diff --git a/src/port/getpeereid.c b/src/port/getpeereid.c index d6aa755d30a..46318691807 100644 --- a/src/port/getpeereid.c +++ b/src/port/getpeereid.c @@ -37,7 +37,7 @@ getpeereid(int sock, uid_t *uid, gid_t *gid) #if defined(SO_PEERCRED) /* Linux: use getsockopt(SO_PEERCRED) */ struct ucred peercred; - ACCEPT_TYPE_ARG3 so_len = sizeof(peercred); + socklen_t so_len = sizeof(peercred); if (getsockopt(sock, SOL_SOCKET, SO_PEERCRED, &peercred, &so_len) != 0 || so_len != sizeof(peercred)) @@ -48,7 +48,7 @@ getpeereid(int sock, uid_t *uid, gid_t *gid) #elif defined(LOCAL_PEERCRED) /* Debian with FreeBSD kernel: use getsockopt(LOCAL_PEERCRED) */ struct xucred peercred; - ACCEPT_TYPE_ARG3 so_len = sizeof(peercred); + socklen_t so_len = sizeof(peercred); if (getsockopt(sock, 0, LOCAL_PEERCRED, &peercred, &so_len) != 0 || so_len != sizeof(peercred) || diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm index 43fd1be0888..a013951e0d8 100644 --- a/src/tools/msvc/Solution.pm +++ b/src/tools/msvc/Solution.pm @@ -205,10 +205,6 @@ sub GenerateFiles # Every symbol in pg_config.h.in must be accounted for here. Set # to undef if the symbol should not be defined. my %define = ( - ACCEPT_TYPE_ARG1 => 'unsigned int', - ACCEPT_TYPE_ARG2 => 'struct sockaddr *', - ACCEPT_TYPE_ARG3 => 'int', - ACCEPT_TYPE_RETURN => 'unsigned int PASCAL', ALIGNOF_DOUBLE => 8, ALIGNOF_INT => 4, ALIGNOF_LONG => 4, @@ -365,6 +361,7 @@ sub GenerateFiles HAVE_SETPROCTITLE_FAST => undef, HAVE_SETSID => undef, HAVE_SHM_OPEN => undef, + HAVE_SOCKLEN_T => 1, HAVE_SPINLOCKS => 1, HAVE_SRANDOM => undef, HAVE_STDBOOL_H => 1, |