summaryrefslogtreecommitdiff
path: root/src/rep.cpp
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2010-02-19 15:25:05 +0100
committerMartin Sustrik <sustrik@250bpm.com>2010-02-19 15:25:05 +0100
commitaff1f6621ae13083c7f15f7f1f808560254a2dcb (patch)
tree9e73dd8bd5d38a21e0aa83b4d4bea55b7792b39e /src/rep.cpp
parent75f571c8844231f4172f131e1dd6ba2348eb54e5 (diff)
parent2a79a943de417679c562cd4a917e1d1bc19b0d25 (diff)
Merge branch 'master' of git@github.com:sustrik/zeromq2
Diffstat (limited to 'src/rep.cpp')
-rw-r--r--src/rep.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/rep.cpp b/src/rep.cpp
index 968427d..755d78e 100644
--- a/src/rep.cpp
+++ b/src/rep.cpp
@@ -89,11 +89,11 @@ void zmq::rep_t::xdetach_outpipe (class writer_t *pipe_)
out_pipes_t::size_type index = out_pipes.index (pipe_);
- // TODO: If the connection we've got the request from disconnects,
- // there's nowhere to send the reply. DLQ?
- if (waiting_for_reply && pipe_ == reply_pipe) {
- zmq_assert (false);
- }
+ // If the connection we've got the request from disconnects,
+ // there's nowhere to send the reply. Forget about the reply pipe.
+ // Once the reply is sent it will be dropped.
+ if (waiting_for_reply && pipe_ == reply_pipe)
+ reply_pipe = NULL;
// If corresponding inpipe is still in place simply nullify the pointer
// to the outpipe.
@@ -150,9 +150,15 @@ int zmq::rep_t::xsend (zmq_msg_t *msg_, int flags_)
// overloads the buffer, connection should be torn down.
zmq_assert (reply_pipe->check_write (zmq_msg_size (msg_)));
- // Push message to the selected pipe.
- reply_pipe->write (msg_);
- reply_pipe->flush ();
+ // Push message to the selected pipe. If requester have disconnected
+ // in the meantime, drop the reply.
+ if (reply_pipe) {
+ reply_pipe->write (msg_);
+ reply_pipe->flush ();
+ }
+ else {
+ zmq_close (msg_);
+ }
waiting_for_reply = false;
reply_pipe = NULL;