mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-17 08:34:00 +00:00
Patch from Mato that fixes a subtle connect bug: EAGAIN was being used as a translation value for EINPROGRESS, thus
shadowing a real EAGAIN return value from the OS. This caused later assertions of "Invalid argument" in stream_engine.cpp when it attempted to use a socket which was not connected. I also add EINTR to mean EINPROGRESS, as per the POSIX and FreeBSD documentation which specifies that a connect() call interrupted due to a signal will complete asynchronously. Signed-off-by: Martin Lucina <martin@lucina.net>
This commit is contained in:
parent
f497aae8df
commit
1075005b50
@ -187,6 +187,13 @@ int zmq::ipc_connecter_t::open ()
|
|||||||
if (rc == 0)
|
if (rc == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
// Translate other error codes indicating asynchronous connect has been
|
||||||
|
// launched to a uniform EINPROGRESS.
|
||||||
|
if (rc == -1 && errno == EINTR) {
|
||||||
|
errno = EINPROGRESS;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
// Forward the error.
|
// Forward the error.
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ void zmq::tcp_connecter_t::start_connecting ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Connection establishment may be delayed. Poll for its completion.
|
// Connection establishment may be delayed. Poll for its completion.
|
||||||
else if (rc == -1 && errno == EAGAIN) {
|
else if (rc == -1 && errno == EINPROGRESS) {
|
||||||
handle = add_fd (s);
|
handle = add_fd (s);
|
||||||
handle_valid = true;
|
handle_valid = true;
|
||||||
set_pollout (handle);
|
set_pollout (handle);
|
||||||
@ -211,17 +211,18 @@ int zmq::tcp_connecter_t::open ()
|
|||||||
if (rc == 0)
|
if (rc == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Asynchronous connect was launched.
|
// Translate other error codes indicating asynchronous connect has been
|
||||||
|
// launched to a uniform EINPROGRESS.
|
||||||
#ifdef ZMQ_HAVE_WINDOWS
|
#ifdef ZMQ_HAVE_WINDOWS
|
||||||
if (rc == SOCKET_ERROR && (WSAGetLastError () == WSAEINPROGRESS ||
|
if (rc == SOCKET_ERROR && (WSAGetLastError () == WSAEINPROGRESS ||
|
||||||
WSAGetLastError () == WSAEWOULDBLOCK)) {
|
WSAGetLastError () == WSAEWOULDBLOCK)) {
|
||||||
errno = EAGAIN;
|
errno = EINPROGRESS;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
wsa_error_to_errno ();
|
wsa_error_to_errno ();
|
||||||
#else
|
#else
|
||||||
if (rc == -1 && errno == EINPROGRESS) {
|
if (rc == -1 && errno == EINTR) {
|
||||||
errno = EAGAIN;
|
errno = EINPROGRESS;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user