0
0
mirror of https://github.com/zeromq/libzmq.git synced 2024-12-31 01:43:02 +08:00

Make socket IO more robust

See also https://zeromq.jira.com/browse/LIBZMQ-433
This commit is contained in:
Martin Hurton 2012-09-29 11:14:44 +02:00
parent 343ec62282
commit 82d7238f08

View File

@ -489,11 +489,20 @@ int zmq::stream_engine_t::write (const void *data_, size_t size_)
return 0;
// Signalise peer failure.
if (nbytes == -1 && (errno == ECONNRESET || errno == EPIPE ||
errno == ETIMEDOUT))
if (nbytes == -1) {
errno_assert (errno != EACCES
&& errno != EBADF
&& errno != EDESTADDRREQ
&& errno != EFAULT
&& errno != EINVAL
&& errno != EISCONN
&& errno != EMSGSIZE
&& errno != ENOMEM
&& errno != ENOTSOCK
&& errno != EOPNOTSUPP);
return -1;
}
errno_assert (nbytes != -1);
return (size_t) nbytes;
#endif
@ -541,11 +550,14 @@ int zmq::stream_engine_t::read (void *data_, size_t size_)
return 0;
// Signalise peer failure.
if (nbytes == -1 && (errno == ECONNRESET || errno == ECONNREFUSED ||
errno == ETIMEDOUT || errno == EHOSTUNREACH || errno == ENOTCONN))
if (nbytes == -1) {
errno_assert (errno != EBADF
&& errno != EFAULT
&& errno != EINVAL
&& errno != ENOMEM
&& errno != ENOTSOCK);
return -1;
errno_assert (nbytes != -1);
}
// Orderly shutdown by the peer.
if (nbytes == 0)