summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/xrep.cpp35
1 files changed, 22 insertions, 13 deletions
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 ();
+ }
}
}