[zeromq-dev] Windows bug fix
Martin Sustrik
sustrik at fastmq.com
Wed Sep 16 09:44:00 CEST 2009
Robin,
> We encountered an issue where a windows app would crash if we were
> sending messages when a listener was down and had never come up. We got
> an assert in tcp_socket.cpp on line 163.
>
> wsa_assert (nbytes != SOCKET_ERROR);
>
> The error being returned from WSAGetLastError () was 10053
> (WSAECONNABORTED).
>
> Not sure if this is the correct change but changing the code above the
> assert to include this error code seemed to make the problem go away.
>
> E.g.
>
> if (nbytes == -1 && (
> WSAGetLastError () == WSAECONNRESET ||
> WSAGetLastError () == WSAECONNREFUSED ||
> WSAGetLastError () == WSAECONNABORTED ||
> WSAGetLastError () == WSAENOTCONN))
> return -1;
I've added couple of error codes to both read & write function that seem
to be recoverable on Windows platform. The change is commited as GIT
rev. 4fb46c8. Here's the diff:
--- a/libzmq/tcp_socket.cpp
+++ b/libzmq/tcp_socket.cpp
@@ -136,7 +136,13 @@ int zmq::tcp_socket_t::write (const void *data, int
size)
return 0;
// Signalise peer failure.
- if (nbytes == SOCKET_ERROR && WSAGetLastError () == WSAECONNRESET)
+ if (nbytes == -1 && (
+ WSAGetLastError () == WSAENETDOWN ||
+ WSAGetLastError () == WSAENETRESET ||
+ WSAGetLastError () == WSAEHOSTUNREACH ||
+ WSAGetLastError () == WSAECONNABORTED ||
+ WSAGetLastError () == WSAETIMEDOUT ||
+ WSAGetLastError () == WSAECONNRESET))
return -1;
wsa_assert (nbytes != SOCKET_ERROR);
@@ -155,6 +161,10 @@ int zmq::tcp_socket_t::read (void *data, int size)
// Connection failure.
if (nbytes == -1 && (
+ WSAGetLastError () == WSAENETDOWN ||
+ WSAGetLastError () == WSAENETRESET ||
+ WSAGetLastError () == WSAECONNABORTED ||
+ WSAGetLastError () == WSAETIMEDOUT ||
WSAGetLastError () == WSAECONNRESET ||
WSAGetLastError () == WSAECONNREFUSED ||
WSAGetLastError () == WSAENOTCONN))
Martin
More information about the zeromq-dev
mailing list