0
0
mirror of https://github.com/zeromq/libzmq.git synced 2024-12-27 15:41:05 +08:00

AF_UNIX support may fail on bind

This commit is contained in:
Min RK 2022-09-08 11:27:46 +02:00
parent b2921d7183
commit bf906ee346
No known key found for this signature in database
GPG Key ID: 809C6E46EAA899F4

View File

@ -577,6 +577,11 @@ int zmq::make_fdpair (fd_t *r_, fd_t *w_)
int rc = 0; int rc = 0;
int saved_errno = 0; int saved_errno = 0;
// It appears that a lack of runtime AF_UNIX support
// can fail in more than one way.
// At least: open_socket can fail or later in bind
bool ipc_fallback_on_tcpip = true;
// Create a listening socket. // Create a listening socket.
const SOCKET listener = open_socket (AF_UNIX, SOCK_STREAM, 0); const SOCKET listener = open_socket (AF_UNIX, SOCK_STREAM, 0);
if (listener == retired_fd) { if (listener == retired_fd) {
@ -599,6 +604,9 @@ int zmq::make_fdpair (fd_t *r_, fd_t *w_)
errno = wsa_error_to_errno (WSAGetLastError ()); errno = wsa_error_to_errno (WSAGetLastError ());
goto error_closelistener; goto error_closelistener;
} }
// if we got here, ipc should be working,
// so raise any remaining errors
ipc_fallback_on_tcpip = false;
// Listen for incoming connections. // Listen for incoming connections.
rc = listen (listener, 1); rc = listen (listener, 1);
@ -665,8 +673,12 @@ error_closelistener:
filename.clear (); filename.clear ();
} }
errno = saved_errno; // ipc failed due to lack of AF_UNIX support, fallback on tcpip
if (ipc_fallback_on_tcpip) {
goto try_tcpip;
}
errno = saved_errno;
return -1; return -1;
try_tcpip: try_tcpip: