Skip to content

Commit

Permalink
Problem: asserts if EINVAL recieved on read/write
Browse files Browse the repository at this point in the history
This causes assertion failures after network reconnects.

Solution: allow EINVAL as a possible condition after read/write.

Fixes zeromq#829
Fixes zeromq#1399

Patch provided by Michele Dionisio @mdionisio, thanks :)
  • Loading branch information
hintjens committed Nov 1, 2015
1 parent aec874c commit 02c1e6d
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions src/tcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ void zmq::tune_tcp_retransmit_timeout (fd_t sockfd_, int timeout_)
&& errno != EBADF
&& errno != EDESTADDRREQ
&& errno != EFAULT
&& errno != EINVAL
&& errno != EISCONN
&& errno != EMSGSIZE
&& errno != ENOMEM
Expand All @@ -240,21 +239,21 @@ int zmq::tcp_read (fd_t s_, void *data_, size_t size_)

// If not a single byte can be read from the socket in non-blocking mode
// we'll get an error (this may happen during the speculative read).
if (rc == SOCKET_ERROR) {
const int last_error = WSAGetLastError();
if (last_error == WSAEWOULDBLOCK) {
errno = EAGAIN;
}
else {
wsa_assert (last_error == WSAENETDOWN ||
last_error == WSAENETRESET ||
last_error == WSAECONNABORTED ||
last_error == WSAETIMEDOUT ||
last_error == WSAECONNRESET ||
last_error == WSAECONNREFUSED ||
last_error == WSAENOTCONN);
errno = wsa_error_to_errno (last_error);
}
if (rc == SOCKET_ERROR) {
const int last_error = WSAGetLastError();
if (last_error == WSAEWOULDBLOCK) {
errno = EAGAIN;
}
else {
wsa_assert (last_error == WSAENETDOWN ||
last_error == WSAENETRESET ||
last_error == WSAECONNABORTED ||
last_error == WSAETIMEDOUT ||
last_error == WSAECONNRESET ||
last_error == WSAECONNREFUSED ||
last_error == WSAENOTCONN);
errno = wsa_error_to_errno (last_error);
}
}

return rc == SOCKET_ERROR ? -1 : rc;
Expand All @@ -269,7 +268,6 @@ int zmq::tcp_read (fd_t s_, void *data_, size_t size_)
if (rc == -1) {
errno_assert (errno != EBADF
&& errno != EFAULT
&& errno != EINVAL
&& errno != ENOMEM
&& errno != ENOTSOCK);
if (errno == EWOULDBLOCK || errno == EINTR)
Expand Down

0 comments on commit 02c1e6d

Please sign in to comment.