>From 8485a5e5a4cdcb5cec800279f874c8579d246940 Mon Sep 17 00:00:00 2001
From: Martin Sustrik <[email protected]>
Date: Wed, 28 Sep 2011 08:03:14 +0200
Subject: [PATCH] Assert fixed in XREP & ROUTER  when sending to terminating pipe (issue 258)

Signed-off-by: Martin Sustrik <[email protected]>
---
 src/router.cpp |    5 +++--
 src/xrep.cpp   |    6 ++++--
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/router.cpp b/src/router.cpp
index c8cc278..05908b5 100755
--- a/src/router.cpp
+++ b/src/router.cpp
@@ -179,8 +179,9 @@ int zmq::router_t::xsend (msg_t *msg_, int flags_)
     //  Push the message into the pipe. If there's no out pipe, just drop it.
     if (current_out) {
         bool ok = current_out->write (msg_);
-        zmq_assert (ok);
-        if (!more_out) {
+        if (unlikely (!ok))
+            current_out = NULL;
+        else if (!more_out) {
             current_out->flush ();
             current_out = NULL;
         }
diff --git a/src/xrep.cpp b/src/xrep.cpp
index c304463..9f2a947 100644
--- a/src/xrep.cpp
+++ b/src/xrep.cpp
@@ -22,6 +22,7 @@
 #include "pipe.hpp"
 #include "wire.hpp"
 #include "random.hpp"
+#include "likely.hpp"
 #include "err.hpp"
 
 zmq::xrep_t::xrep_t (class ctx_t *parent_, uint32_t tid_) :
@@ -163,8 +164,9 @@ int zmq::xrep_t::xsend (msg_t *msg_, int flags_)
     //  Push the message into the pipe. If there's no out pipe, just drop it.
     if (current_out) {
         bool ok = current_out->write (msg_);
-        zmq_assert (ok);
-        if (!more_out) {
+        if (unlikely (!ok))
+            current_out = NULL;
+        else if (!more_out) {
             current_out->flush ();
             current_out = NULL;
         }
-- 
1.7.0.4

_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to