mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-04 16:47:21 +02:00
Provide errno-translation wrappers around bind() and listen() on Windows.
Fix Windows builds to report something useful rather than "could not bind IPv4 socket: No error" when bind() fails. Back-patch of commitsd1b7d4877b
and22989a8e34
. Discussion: <4065.1452450340@sss.pgh.pa.us>
This commit is contained in:
parent
4b52cc2892
commit
20d4428f09
@ -27,7 +27,10 @@
|
|||||||
*/
|
*/
|
||||||
int pgwin32_noblock = 0;
|
int pgwin32_noblock = 0;
|
||||||
|
|
||||||
|
/* Undef the macros defined in win32.h, so we can access system functions */
|
||||||
#undef socket
|
#undef socket
|
||||||
|
#undef bind
|
||||||
|
#undef listen
|
||||||
#undef accept
|
#undef accept
|
||||||
#undef connect
|
#undef connect
|
||||||
#undef select
|
#undef select
|
||||||
@ -261,6 +264,27 @@ pgwin32_socket(int af, int type, int protocol)
|
|||||||
return s;
|
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
|
SOCKET
|
||||||
pgwin32_accept(SOCKET s, struct sockaddr * addr, int *addrlen)
|
pgwin32_accept(SOCKET s, struct sockaddr * addr, int *addrlen)
|
||||||
|
@ -364,6 +364,8 @@ void pg_queue_signal(int signum);
|
|||||||
/* In backend/port/win32/socket.c */
|
/* In backend/port/win32/socket.c */
|
||||||
#ifndef FRONTEND
|
#ifndef FRONTEND
|
||||||
#define socket(af, type, protocol) pgwin32_socket(af, type, protocol)
|
#define socket(af, type, protocol) pgwin32_socket(af, type, protocol)
|
||||||
|
#define bind(s, addr, addrlen) pgwin32_bind(s, addr, addrlen)
|
||||||
|
#define listen(s, backlog) pgwin32_listen(s, backlog)
|
||||||
#define accept(s, addr, addrlen) pgwin32_accept(s, addr, addrlen)
|
#define accept(s, addr, addrlen) pgwin32_accept(s, addr, addrlen)
|
||||||
#define connect(s, name, namelen) pgwin32_connect(s, name, namelen)
|
#define connect(s, name, namelen) pgwin32_connect(s, name, namelen)
|
||||||
#define select(n, r, w, e, timeout) pgwin32_select(n, r, w, e, timeout)
|
#define select(n, r, w, e, timeout) pgwin32_select(n, r, w, e, timeout)
|
||||||
@ -371,6 +373,8 @@ void pg_queue_signal(int signum);
|
|||||||
#define send(s, buf, len, flags) pgwin32_send(s, buf, len, flags)
|
#define send(s, buf, len, flags) pgwin32_send(s, buf, len, flags)
|
||||||
|
|
||||||
SOCKET pgwin32_socket(int af, int type, int protocol);
|
SOCKET pgwin32_socket(int af, int type, int protocol);
|
||||||
|
int pgwin32_bind(SOCKET s, struct sockaddr * addr, int addrlen);
|
||||||
|
int pgwin32_listen(SOCKET s, int backlog);
|
||||||
SOCKET pgwin32_accept(SOCKET s, struct sockaddr * addr, int *addrlen);
|
SOCKET pgwin32_accept(SOCKET s, struct sockaddr * addr, int *addrlen);
|
||||||
int pgwin32_connect(SOCKET s, const struct sockaddr * name, int namelen);
|
int pgwin32_connect(SOCKET s, const struct sockaddr * name, int namelen);
|
||||||
int pgwin32_select(int nfds, fd_set *readfs, fd_set *writefds, fd_set *exceptfds, const struct timeval * timeout);
|
int pgwin32_select(int nfds, fd_set *readfs, fd_set *writefds, fd_set *exceptfds, const struct timeval * timeout);
|
||||||
|
Loading…
Reference in New Issue
Block a user