summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--devices/zmq_forwarder/zmq_forwarder.cpp6
-rw-r--r--devices/zmq_queue/zmq_queue.cpp6
-rw-r--r--devices/zmq_streamer/zmq_streamer.cpp6
-rw-r--r--src/device.cpp33
4 files changed, 26 insertions, 25 deletions
diff --git a/devices/zmq_forwarder/zmq_forwarder.cpp b/devices/zmq_forwarder/zmq_forwarder.cpp
index 88a92d1..c28b461 100644
--- a/devices/zmq_forwarder/zmq_forwarder.cpp
+++ b/devices/zmq_forwarder/zmq_forwarder.cpp
@@ -113,7 +113,11 @@ int main (int argc, char *argv [])
n++;
}
- zmq::device (ZMQ_FORWARDER, in_socket, out_socket);
+ try {
+ zmq::device (ZMQ_FORWARDER, in_socket, out_socket);
+ } catch (zmq::error_t& e) {
+ fprintf(stderr, "device exit: %s\n", e.what());
+ }
return 0;
}
diff --git a/devices/zmq_queue/zmq_queue.cpp b/devices/zmq_queue/zmq_queue.cpp
index 284bf9a..09e3304 100644
--- a/devices/zmq_queue/zmq_queue.cpp
+++ b/devices/zmq_queue/zmq_queue.cpp
@@ -112,7 +112,11 @@ int main (int argc, char *argv [])
n++;
}
- zmq::device (ZMQ_QUEUE, in_socket, out_socket);
+ try {
+ zmq::device (ZMQ_QUEUE, in_socket, out_socket);
+ } catch (zmq::error_t& e) {
+ fprintf(stderr, "device exit: %s\n", e.what());
+ }
return 0;
}
diff --git a/devices/zmq_streamer/zmq_streamer.cpp b/devices/zmq_streamer/zmq_streamer.cpp
index 242d03f..9b57074 100644
--- a/devices/zmq_streamer/zmq_streamer.cpp
+++ b/devices/zmq_streamer/zmq_streamer.cpp
@@ -112,7 +112,11 @@ int main (int argc, char *argv [])
n++;
}
- zmq::device (ZMQ_FORWARDER, in_socket, out_socket);
+ try {
+ zmq::device (ZMQ_STREAMER, in_socket, out_socket);
+ } catch (zmq::error_t& e) {
+ fprintf(stderr, "device exit: %s\n", e.what());
+ }
return 0;
}
diff --git a/src/device.cpp b/src/device.cpp
index e7c6090..cf1f9f6 100644
--- a/src/device.cpp
+++ b/src/device.cpp
@@ -31,7 +31,10 @@ int zmq::device (class socket_base_t *insocket_,
{
zmq_msg_t msg;
int rc = zmq_msg_init (&msg);
- zmq_assert (rc == 0);
+
+ if (rc != 0) {
+ return -1;
+ }
int64_t more;
size_t moresz;
@@ -51,9 +54,7 @@ int zmq::device (class socket_base_t *insocket_,
// Wait while there are either requests or replies to process.
rc = zmq_poll (&items [0], 2, -1);
if (unlikely (rc < 0)) {
- if (errno == ETERM)
- return -1;
- errno_assert (false);
+ return -1;
}
// The algorithm below asumes ratio of request and replies processed
@@ -67,24 +68,18 @@ int zmq::device (class socket_base_t *insocket_,
rc = insocket_->recv (&msg, 0);
if (unlikely (rc < 0)) {
- if (errno == ETERM)
- return -1;
- errno_assert (false);
+ return -1;
}
moresz = sizeof (more);
rc = insocket_->getsockopt (ZMQ_RCVMORE, &more, &moresz);
if (unlikely (rc < 0)) {
- if (errno == ETERM)
- return -1;
- errno_assert (false);
+ return -1;
}
rc = outsocket_->send (&msg, more ? ZMQ_SNDMORE : 0);
if (unlikely (rc < 0)) {
- if (errno == ETERM)
- return -1;
- errno_assert (false);
+ return -1;
}
if (!more)
@@ -98,24 +93,18 @@ int zmq::device (class socket_base_t *insocket_,
rc = outsocket_->recv (&msg, 0);
if (unlikely (rc < 0)) {
- if (errno == ETERM)
- return -1;
- errno_assert (false);
+ return -1;
}
moresz = sizeof (more);
rc = outsocket_->getsockopt (ZMQ_RCVMORE, &more, &moresz);
if (unlikely (rc < 0)) {
- if (errno == ETERM)
- return -1;
- errno_assert (false);
+ return -1;
}
rc = insocket_->send (&msg, more ? ZMQ_SNDMORE : 0);
if (unlikely (rc < 0)) {
- if (errno == ETERM)
- return -1;
- errno_assert (false);
+ return -1;
}
if (!more)