From 0bb76b667b277b143a9a2901e8bf407f34da469d Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Fri, 1 Oct 2010 13:37:46 +0200 Subject: assert when xrep socket gets reconnected in the middle of the shutdown -- fixed --- src/xrep.cpp | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'src/xrep.cpp') diff --git a/src/xrep.cpp b/src/xrep.cpp index a6c3cf6..96f991a 100644 --- a/src/xrep.cpp +++ b/src/xrep.cpp @@ -50,24 +50,33 @@ zmq::xrep_t::~xrep_t () void zmq::xrep_t::xattach_pipes (reader_t *inpipe_, writer_t *outpipe_, const blob_t &peer_identity_) { - zmq_assert (inpipe_ && outpipe_); + if (outpipe_) { - outpipe_->set_event_sink (this); + outpipe_->set_event_sink (this); - // TODO: What if new connection has same peer identity as the old one? - outpipe_t outpipe = {outpipe_, true}; - bool ok = outpipes.insert (std::make_pair ( - peer_identity_, outpipe)).second; - zmq_assert (ok); + // TODO: What if new connection has same peer identity as the old one? + outpipe_t outpipe = {outpipe_, true}; + bool ok = outpipes.insert (std::make_pair ( + peer_identity_, outpipe)).second; + zmq_assert (ok); + + if (terminating) { + register_term_acks (1); + outpipe_->terminate (); + } + } + + if (inpipe_) { - inpipe_->set_event_sink (this); + inpipe_->set_event_sink (this); - inpipe_t inpipe = {inpipe_, peer_identity_, true}; - inpipes.push_back (inpipe); + inpipe_t inpipe = {inpipe_, peer_identity_, true}; + inpipes.push_back (inpipe); - if (terminating) { - register_term_acks (1); - inpipe_->terminate (); + if (terminating) { + register_term_acks (1); + inpipe_->terminate (); + } } } -- cgit v1.2.3