From 5d76925f90ddae386c0aa11171fdd89ac03227f8 Mon Sep 17 00:00:00 2001 From: leiyz <280838230@qq.com> Date: Thu, 30 Dec 2021 18:28:24 +0800 Subject: [PATCH] zmq_recv zmq_send handle EINTR --- zmq.hpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/zmq.hpp b/zmq.hpp index b4629b0..5be1aeb 100644 --- a/zmq.hpp +++ b/zmq.hpp @@ -1889,7 +1889,7 @@ class socket_base int nbytes = zmq_send(_handle, buf_, len_, flags_); if (nbytes >= 0) return static_cast(nbytes); - if (zmq_errno() == EAGAIN) + if (zmq_errno() == EAGAIN || zmq_errno() == EINTR) return 0; throw error_t(); } @@ -1901,7 +1901,7 @@ class socket_base int nbytes = zmq_msg_send(msg_.handle(), _handle, flags_); if (nbytes >= 0) return true; - if (zmq_errno() == EAGAIN) + if (zmq_errno() == EAGAIN || zmq_errno() == EINTR) return false; throw error_t(); } @@ -1916,7 +1916,7 @@ class socket_base int nbytes = zmq_msg_send(msg.handle(), _handle, flags_); if (nbytes >= 0) return true; - if (zmq_errno() == EAGAIN) + if (zmq_errno() == EAGAIN || zmq_errno() == EINTR) return false; throw error_t(); } @@ -1941,7 +1941,7 @@ class socket_base zmq_send(_handle, buf.data(), buf.size(), static_cast(flags)); if (nbytes >= 0) return static_cast(nbytes); - if (zmq_errno() == EAGAIN) + if (zmq_errno() == EAGAIN || zmq_errno() == EINTR) return {}; throw error_t(); } @@ -1951,7 +1951,7 @@ class socket_base int nbytes = zmq_msg_send(msg.handle(), _handle, static_cast(flags)); if (nbytes >= 0) return static_cast(nbytes); - if (zmq_errno() == EAGAIN) + if (zmq_errno() == EAGAIN || zmq_errno() == EINTR) return {}; throw error_t(); } @@ -1969,7 +1969,7 @@ class socket_base int nbytes = zmq_recv(_handle, buf_, len_, flags_); if (nbytes >= 0) return static_cast(nbytes); - if (zmq_errno() == EAGAIN) + if (zmq_errno() == EAGAIN || zmq_errno() == EINTR) return 0; throw error_t(); } @@ -1981,7 +1981,7 @@ class socket_base int nbytes = zmq_msg_recv(msg_->handle(), _handle, flags_); if (nbytes >= 0) return true; - if (zmq_errno() == EAGAIN) + if (zmq_errno() == EAGAIN || zmq_errno() == EINTR) return false; throw error_t(); } @@ -1998,7 +1998,7 @@ class socket_base (std::min)(static_cast(nbytes), buf.size()), static_cast(nbytes)}; } - if (zmq_errno() == EAGAIN) + if (zmq_errno() == EAGAIN || zmq_errno() == EINTR) return {}; throw error_t(); } @@ -2012,7 +2012,7 @@ class socket_base assert(msg.size() == static_cast(nbytes)); return static_cast(nbytes); } - if (zmq_errno() == EAGAIN) + if (zmq_errno() == EAGAIN || zmq_errno() == EINTR) return {}; throw error_t(); } @@ -2662,7 +2662,7 @@ template class poller_t return static_cast(rc); #if ZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 2, 3) - if (zmq_errno() == EAGAIN) + if (zmq_errno() == EAGAIN || zmq_errno() == EINTR) #else if (zmq_errno() == ETIMEDOUT) #endif