mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-17 03:03:25 +02:00
Problem: SIO_LOOPBACK_FAST_PATH not activated for signaler socket pair
Solution: activate SIO_LOOPBACK_FAST_PATH if available See #2899
This commit is contained in:
@@ -384,6 +384,33 @@ void zmq::signaler_t::forked ()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined ZMQ_HAVE_WINDOWS
|
||||||
|
static void tune_socket (const SOCKET socket)
|
||||||
|
{
|
||||||
|
BOOL tcp_nodelay = 1;
|
||||||
|
int rc = setsockopt (socket, IPPROTO_TCP, TCP_NODELAY,
|
||||||
|
(char *) &tcp_nodelay, sizeof tcp_nodelay);
|
||||||
|
wsa_assert (rc != SOCKET_ERROR);
|
||||||
|
|
||||||
|
int sio_loopback_fastpath = 1;
|
||||||
|
DWORD numberOfBytesReturned = 0;
|
||||||
|
|
||||||
|
rc = WSAIoctl (socket, SIO_LOOPBACK_FAST_PATH, &sio_loopback_fastpath,
|
||||||
|
sizeof sio_loopback_fastpath, NULL, 0,
|
||||||
|
&numberOfBytesReturned, 0, 0);
|
||||||
|
|
||||||
|
if (SOCKET_ERROR == rc) {
|
||||||
|
DWORD lastError = ::WSAGetLastError ();
|
||||||
|
|
||||||
|
if (WSAEOPNOTSUPP == lastError) {
|
||||||
|
// This system is not Windows 8 or Server 2012, and the call is not supported.
|
||||||
|
} else {
|
||||||
|
wsa_assert (false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Returns -1 if we could not make the socket pair successfully
|
// Returns -1 if we could not make the socket pair successfully
|
||||||
int zmq::signaler_t::make_fdpair (fd_t *r_, fd_t *w_)
|
int zmq::signaler_t::make_fdpair (fd_t *r_, fd_t *w_)
|
||||||
{
|
{
|
||||||
@@ -483,10 +510,8 @@ int zmq::signaler_t::make_fdpair (fd_t *r_, fd_t *w_)
|
|||||||
int rc = setsockopt (listener, SOL_SOCKET, SO_REUSEADDR,
|
int rc = setsockopt (listener, SOL_SOCKET, SO_REUSEADDR,
|
||||||
(char *) &so_reuseaddr, sizeof so_reuseaddr);
|
(char *) &so_reuseaddr, sizeof so_reuseaddr);
|
||||||
wsa_assert (rc != SOCKET_ERROR);
|
wsa_assert (rc != SOCKET_ERROR);
|
||||||
BOOL tcp_nodelay = 1;
|
|
||||||
rc = setsockopt (listener, IPPROTO_TCP, TCP_NODELAY, (char *) &tcp_nodelay,
|
tune_socket (listener);
|
||||||
sizeof tcp_nodelay);
|
|
||||||
wsa_assert (rc != SOCKET_ERROR);
|
|
||||||
|
|
||||||
// Init sockaddr to signaler port.
|
// Init sockaddr to signaler port.
|
||||||
struct sockaddr_in addr;
|
struct sockaddr_in addr;
|
||||||
@@ -500,9 +525,7 @@ int zmq::signaler_t::make_fdpair (fd_t *r_, fd_t *w_)
|
|||||||
wsa_assert (*w_ != INVALID_SOCKET);
|
wsa_assert (*w_ != INVALID_SOCKET);
|
||||||
|
|
||||||
// Set TCP_NODELAY on writer socket.
|
// Set TCP_NODELAY on writer socket.
|
||||||
rc = setsockopt (*w_, IPPROTO_TCP, TCP_NODELAY, (char *) &tcp_nodelay,
|
tune_socket (*w_);
|
||||||
sizeof tcp_nodelay);
|
|
||||||
wsa_assert (rc != SOCKET_ERROR);
|
|
||||||
|
|
||||||
if (sync != NULL) {
|
if (sync != NULL) {
|
||||||
// Enter the critical section.
|
// Enter the critical section.
|
||||||
|
Reference in New Issue
Block a user