summaryrefslogtreecommitdiff
path: root/src/backend/libpq/pqcomm.c
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2014-04-16 10:45:48 -0400
committerBruce Momjian <bruce@momjian.us>2014-04-16 10:45:48 -0400
commitbed499ed1d94f05195c63387d4629644e0df4149 (patch)
tree396380e598db0f2ab5c352581acb3522226ea59b /src/backend/libpq/pqcomm.c
parent61df3d090c0e42fd0ad06e5a3d70aca148107c30 (diff)
check socket creation errors against PGINVALID_SOCKET
Previously, in some places, socket creation errors were checked for negative values, which is not true for Windows because sockets are unsigned. This masked socket creation errors on Windows. Backpatch through 9.0. 8.4 doesn't have the infrastructure to fix this.
Diffstat (limited to 'src/backend/libpq/pqcomm.c')
-rw-r--r--src/backend/libpq/pqcomm.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c
index c79c846a660..2a1fc145ee6 100644
--- a/src/backend/libpq/pqcomm.c
+++ b/src/backend/libpq/pqcomm.c
@@ -363,7 +363,7 @@ StreamServerPort(int family, char *hostName, unsigned short portNumber,
break;
}
- if ((fd = socket(addr->ai_family, SOCK_STREAM, 0)) < 0)
+ if ((fd = socket(addr->ai_family, SOCK_STREAM, 0)) == PGINVALID_SOCKET)
{
ereport(LOG,
(errcode_for_socket_access(),
@@ -606,7 +606,7 @@ StreamConnection(pgsocket server_fd, Port *port)
port->raddr.salen = sizeof(port->raddr.addr);
if ((port->sock = accept(server_fd,
(struct sockaddr *) & port->raddr.addr,
- &port->raddr.salen)) < 0)
+ &port->raddr.salen)) == PGINVALID_SOCKET)
{
ereport(LOG,
(errcode_for_socket_access(),