From da49e5a4dd4602bf893193a5e6e64af54695b51c Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Tue, 13 Jul 2010 07:57:29 +0200 Subject: devices exit in case of context termination --- src/queue.cpp | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) (limited to 'src/queue.cpp') diff --git a/src/queue.cpp b/src/queue.cpp index 470ea67..311a8c1 100644 --- a/src/queue.cpp +++ b/src/queue.cpp @@ -49,7 +49,11 @@ int zmq::queue (class socket_base_t *insocket_, // Wait while there are either requests or replies to process. rc = zmq_poll (&items [0], 2, -1); - errno_assert (rc > 0); + if (rc < 0) { + if (errno == ETERM) + return -1; + errno_assert (false); + } // The algorithm below asumes ratio of request and replies processed // under full load to be 1:1. Although processing requests replies @@ -61,14 +65,26 @@ int zmq::queue (class socket_base_t *insocket_, while (true) { rc = insocket_->recv (&msg, 0); - errno_assert (rc == 0); + if (rc < 0) { + if (errno == ETERM) + return -1; + errno_assert (false); + } moresz = sizeof (more); rc = insocket_->getsockopt (ZMQ_RCVMORE, &more, &moresz); - errno_assert (rc == 0); + if (rc < 0) { + if (errno == ETERM) + return -1; + errno_assert (false); + } rc = outsocket_->send (&msg, more ? ZMQ_SNDMORE : 0); - errno_assert (rc == 0); + if (rc < 0) { + if (errno == ETERM) + return -1; + errno_assert (false); + } if (!more) break; @@ -80,14 +96,26 @@ int zmq::queue (class socket_base_t *insocket_, while (true) { rc = outsocket_->recv (&msg, 0); - errno_assert (rc == 0); + if (rc < 0) { + if (errno == ETERM) + return -1; + errno_assert (false); + } moresz = sizeof (more); rc = outsocket_->getsockopt (ZMQ_RCVMORE, &more, &moresz); - errno_assert (rc == 0); + if (rc < 0) { + if (errno == ETERM) + return -1; + errno_assert (false); + } rc = insocket_->send (&msg, more ? ZMQ_SNDMORE : 0); - errno_assert (rc == 0); + if (rc < 0) { + if (errno == ETERM) + return -1; + errno_assert (false); + } if (!more) break; -- cgit v1.2.3