Commit 9d8623b2 authored by Martin Sustrik's avatar Martin Sustrik

ZMQII-76: Bug in how replies are handled when the REQ endpoint goes away

parent 33cb20a7
...@@ -85,11 +85,11 @@ void zmq::rep_t::xdetach_outpipe (class writer_t *pipe_) ...@@ -85,11 +85,11 @@ void zmq::rep_t::xdetach_outpipe (class writer_t *pipe_)
out_pipes_t::size_type index = out_pipes.index (pipe_); out_pipes_t::size_type index = out_pipes.index (pipe_);
// TODO: If the connection we've got the request from disconnects, // If the connection we've got the request from disconnects,
// there's nowhere to send the reply. DLQ? // there's nowhere to send the reply. Forget about the reply pipe.
if (waiting_for_reply && pipe_ == reply_pipe) { // Once the reply is sent it will be dropped.
zmq_assert (false); if (waiting_for_reply && pipe_ == reply_pipe)
} reply_pipe = NULL;
// If corresponding inpipe is still in place simply nullify the pointer // If corresponding inpipe is still in place simply nullify the pointer
// to the outpipe. // to the outpipe.
...@@ -146,9 +146,15 @@ int zmq::rep_t::xsend (zmq_msg_t *msg_, int flags_) ...@@ -146,9 +146,15 @@ int zmq::rep_t::xsend (zmq_msg_t *msg_, int flags_)
// overloads the buffer, connection should be torn down. // overloads the buffer, connection should be torn down.
zmq_assert (reply_pipe->check_write (zmq_msg_size (msg_))); zmq_assert (reply_pipe->check_write (zmq_msg_size (msg_)));
// Push message to the selected pipe. // Push message to the selected pipe. If requester have disconnected
reply_pipe->write (msg_); // in the meantime, drop the reply.
reply_pipe->flush (); if (reply_pipe) {
reply_pipe->write (msg_);
reply_pipe->flush ();
}
else {
zmq_close (msg_);
}
waiting_for_reply = false; waiting_for_reply = false;
reply_pipe = NULL; reply_pipe = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment