1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-12 21:01:52 +03:00

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.
This commit is contained in:
Bruce Momjian
2014-04-16 10:45:48 -04:00
parent 848b9f05ab
commit 4180934651
7 changed files with 42 additions and 17 deletions

View File

@ -1463,7 +1463,7 @@ ident_inet(hbaPort *port)
sock_fd = socket(ident_serv->ai_family, ident_serv->ai_socktype,
ident_serv->ai_protocol);
if (sock_fd < 0)
if (sock_fd == PGINVALID_SOCKET)
{
ereport(LOG,
(errcode_for_socket_access(),
@ -1543,7 +1543,7 @@ ident_inet(hbaPort *port)
ident_response)));
ident_inet_done:
if (sock_fd >= 0)
if (sock_fd != PGINVALID_SOCKET)
closesocket(sock_fd);
pg_freeaddrinfo_all(remote_addr.addr.ss_family, ident_serv);
pg_freeaddrinfo_all(local_addr.addr.ss_family, la);
@ -2361,7 +2361,7 @@ CheckRADIUSAuth(Port *port)
packet->length = htons(packet->length);
sock = socket(serveraddrs[0].ai_family, SOCK_DGRAM, 0);
if (sock < 0)
if (sock == PGINVALID_SOCKET)
{
ereport(LOG,
(errmsg("could not create RADIUS socket: %m")));