mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Provide errno-translation wrappers around bind() and listen() on Windows.
I've seen one too many "could not bind IPv4 socket: No error" log entries from the Windows buildfarm members. Per previous discussion, this is likely caused by the fact that we're doing nothing to translate WSAGetLastError() to errno. Put in a wrapper layer to do that. If this works as expected, it should get back-patched, but let's see what happens in the buildfarm first. Discussion: <4065.1452450340@sss.pgh.pa.us>
This commit is contained in:
@ -27,7 +27,10 @@
|
||||
*/
|
||||
int pgwin32_noblock = 0;
|
||||
|
||||
/* Undef the macros defined in win32.h, so we can access system functions */
|
||||
#undef socket
|
||||
#undef bind
|
||||
#undef listen
|
||||
#undef accept
|
||||
#undef connect
|
||||
#undef select
|
||||
@ -261,6 +264,27 @@ pgwin32_socket(int af, int type, int protocol)
|
||||
return s;
|
||||
}
|
||||
|
||||
int
|
||||
pgwin32_bind(SOCKET s, struct sockaddr * addr, int *addrlen)
|
||||
{
|
||||
int res;
|
||||
|
||||
res = bind(s, addr, addrlen);
|
||||
if (res < 0)
|
||||
TranslateSocketError();
|
||||
return res;
|
||||
}
|
||||
|
||||
int
|
||||
pgwin32_listen(SOCKET s, int backlog)
|
||||
{
|
||||
int res;
|
||||
|
||||
res = listen(s, backlog);
|
||||
if (res < 0)
|
||||
TranslateSocketError();
|
||||
return res;
|
||||
}
|
||||
|
||||
SOCKET
|
||||
pgwin32_accept(SOCKET s, struct sockaddr * addr, int *addrlen)
|
||||
|
Reference in New Issue
Block a user