summaryrefslogtreecommitdiff
path: root/src/backend/postmaster
diff options
context:
space:
mode:
authorAndres Freund2017-10-01 22:36:14 +0000
committerAndres Freund2017-10-01 22:36:14 +0000
commit0ba99c84e8c7138143059b281063d4cca5a2bfea (patch)
tree521367c1888ca186fa229efc3489fb4298c8dc08 /src/backend/postmaster
parent1f2830f9df9f0196ba541c1e253463afe657cb67 (diff)
Replace most usages of ntoh[ls] and hton[sl] with pg_bswap.h.
All postgres internal usages are replaced, it's just libpq example usages that haven't been converted. External users of libpq can't generally rely on including postgres internal headers. Note that this includes replacing open-coded byte swapping of 64bit integers (using two 32 bit swaps) with a single 64bit swap. Where it looked applicable, I have removed netinet/in.h and arpa/inet.h usage, which previously provided the relevant functionality. It's perfectly possible that I missed other reasons for including those, the buildfarm will tell. Author: Andres Freund Discussion: https://postgr.es/m/20170927172019.gheidqy6xvlxb325@alap3.anarazel.de
Diffstat (limited to 'src/backend/postmaster')
-rw-r--r--src/backend/postmaster/postmaster.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index 8a2cc2fc2b4..2b2b993e2cf 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -74,8 +74,6 @@
#include <sys/socket.h>
#include <fcntl.h>
#include <sys/param.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
#include <netdb.h>
#include <limits.h>
@@ -107,6 +105,7 @@
#include "miscadmin.h"
#include "pg_getopt.h"
#include "pgstat.h"
+#include "port/pg_bswap.h"
#include "postmaster/autovacuum.h"
#include "postmaster/bgworker_internals.h"
#include "postmaster/fork_process.h"
@@ -1072,7 +1071,7 @@ PostmasterMain(int argc, char *argv[])
"_postgresql._tcp.",
NULL,
NULL,
- htons(PostPortNumber),
+ pg_hton16(PostPortNumber),
0,
NULL,
NULL,
@@ -1966,7 +1965,7 @@ ProcessStartupPacket(Port *port, bool SSLdone)
return STATUS_ERROR;
}
- len = ntohl(len);
+ len = pg_ntoh32(len);
len -= 4;
if (len < (int32) sizeof(ProtocolVersion) ||
@@ -2002,7 +2001,7 @@ ProcessStartupPacket(Port *port, bool SSLdone)
* The first field is either a protocol version number or a special
* request code.
*/
- port->proto = proto = ntohl(*((ProtocolVersion *) buf));
+ port->proto = proto = pg_ntoh32(*((ProtocolVersion *) buf));
if (proto == CANCEL_REQUEST_CODE)
{
@@ -2281,8 +2280,8 @@ processCancelRequest(Port *port, void *pkt)
int i;
#endif
- backendPID = (int) ntohl(canc->backendPID);
- cancelAuthCode = (int32) ntohl(canc->cancelAuthCode);
+ backendPID = (int) pg_ntoh32(canc->backendPID);
+ cancelAuthCode = (int32) pg_ntoh32(canc->cancelAuthCode);
/*
* See if we have a matching backend. In the EXEC_BACKEND case, we can no