summaryrefslogtreecommitdiff
path: root/src/backend/libpq
diff options
context:
space:
mode:
authorMagnus Hagander2010-01-10 14:16:08 +0000
committerMagnus Hagander2010-01-10 14:16:08 +0000
commit87091cb1f1ed914e2ddca424fa28f94fdf8461d2 (patch)
treeec717192f02f29f0f2a7b602e0020d43fc584f61 /src/backend/libpq
parent84b6d5f35941a0406210e7938d10c3cce4e11340 (diff)
Create typedef pgsocket for storing socket descriptors.
This silences some warnings on Win64. Not using the proper SOCKET datatype was actually wrong on Win32 as well, but didn't cause any warnings there. Also create define PGINVALID_SOCKET to indicate an invalid/non-existing socket, instead of using a hardcoded -1 value.
Diffstat (limited to 'src/backend/libpq')
-rw-r--r--src/backend/libpq/auth.c4
-rw-r--r--src/backend/libpq/ip.c6
-rw-r--r--src/backend/libpq/pqcomm.c20
3 files changed, 15 insertions, 15 deletions
diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c
index 4344b0bfaa0..e7d0dbb2985 100644
--- a/src/backend/libpq/auth.c
+++ b/src/backend/libpq/auth.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/libpq/auth.c,v 1.190 2010/01/02 16:57:45 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/libpq/auth.c,v 1.191 2010/01/10 14:16:07 mha Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1497,7 +1497,7 @@ ident_inet(const SockAddr remote_addr,
const SockAddr local_addr,
char *ident_user)
{
- int sock_fd, /* File descriptor for socket on which we talk
+ pgsocket sock_fd, /* File descriptor for socket on which we talk
* to Ident */
rc; /* Return code from a locally called function */
bool ident_return;
diff --git a/src/backend/libpq/ip.c b/src/backend/libpq/ip.c
index b0085cf6bf9..778b9f9ea4a 100644
--- a/src/backend/libpq/ip.c
+++ b/src/backend/libpq/ip.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/libpq/ip.c,v 1.49 2010/01/02 16:57:45 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/libpq/ip.c,v 1.50 2010/01/10 14:16:07 mha Exp $
*
* This file and the IPV6 implementation were initially provided by
* Nigel Kukard <nkukard@lbsd.net>, Linux Based Systems Design
@@ -656,9 +656,9 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data)
struct sockaddr *addr, *mask;
char *ptr, *buffer = NULL;
size_t n_buffer = 1024;
- int sock, fd;
+ pgsocket sock, fd;
#ifdef HAVE_IPV6
- int sock6;
+ pgsocket sock6;
#endif
int i, total;
diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c
index 8800fa6f213..b99c9da2ab5 100644
--- a/src/backend/libpq/pqcomm.c
+++ b/src/backend/libpq/pqcomm.c
@@ -30,7 +30,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/libpq/pqcomm.c,v 1.200 2010/01/02 16:57:45 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/libpq/pqcomm.c,v 1.201 2010/01/10 14:16:07 mha Exp $
*
*-------------------------------------------------------------------------
*/
@@ -199,9 +199,9 @@ pq_close(int code, Datum arg)
* transport layer reports connection closure, and you can be sure the
* backend has exited.
*
- * We do set sock to -1 to prevent any further I/O, though.
+ * We do set sock to PGINVALID_SOCKET to prevent any further I/O, though.
*/
- MyProcPort->sock = -1;
+ MyProcPort->sock = PGINVALID_SOCKET;
}
}
@@ -232,7 +232,7 @@ StreamDoUnlink(int code, Datum arg)
* StreamServerPort -- open a "listening" port to accept connections.
*
* Successfully opened sockets are added to the ListenSocket[] array,
- * at the first position that isn't -1.
+ * at the first position that isn't PGINVALID_SOCKET.
*
* RETURNS: STATUS_OK or STATUS_ERROR
*/
@@ -240,10 +240,10 @@ StreamDoUnlink(int code, Datum arg)
int
StreamServerPort(int family, char *hostName, unsigned short portNumber,
char *unixSocketName,
- int ListenSocket[], int MaxListen)
+ pgsocket ListenSocket[], int MaxListen)
{
- int fd,
- err;
+ pgsocket fd;
+ int err;
int maxconn;
int ret;
char portNumberStr[32];
@@ -311,7 +311,7 @@ StreamServerPort(int family, char *hostName, unsigned short portNumber,
/* See if there is still room to add 1 more socket. */
for (; listen_index < MaxListen; listen_index++)
{
- if (ListenSocket[listen_index] == -1)
+ if (ListenSocket[listen_index] == PGINVALID_SOCKET)
break;
}
if (listen_index >= MaxListen)
@@ -570,7 +570,7 @@ Setup_AF_UNIX(void)
* RETURNS: STATUS_OK or STATUS_ERROR
*/
int
-StreamConnection(int server_fd, Port *port)
+StreamConnection(pgsocket server_fd, Port *port)
{
/* accept connection and fill in the client (remote) address */
port->raddr.salen = sizeof(port->raddr.addr);
@@ -676,7 +676,7 @@ StreamConnection(int server_fd, Port *port)
* we do NOT want to send anything to the far end.
*/
void
-StreamClose(int sock)
+StreamClose(pgsocket sock)
{
closesocket(sock);
}