Commit d8470949 authored by Martin Hurton's avatar Martin Hurton

Do not crash when multiple peers connect to PAIR socket

When more then one peer connected to a ZMQ_PAIR socket,
an application aborted due to assertion failure.
This patch changes the ZMQ_PAIR socket behaviour so that
it rejects any further connection requests.
parent 16ec2868
......@@ -38,14 +38,20 @@ zmq::pair_t::~pair_t ()
void zmq::pair_t::xattach_pipe (pipe_t *pipe_, bool icanhasall_)
{
zmq_assert (!pipe);
pipe = pipe_;
zmq_assert (pipe_ != NULL);
// ZMQ_PAIR socket can only be connected to a single peer.
// The socket rejects any further connection requests.
if (pipe == NULL)
pipe = pipe_;
else
pipe_->terminate (false);
}
void zmq::pair_t::xterminated (pipe_t *pipe_)
{
zmq_assert (pipe_ == pipe);
pipe = NULL;
if (pipe_ == pipe)
pipe = NULL;
}
void zmq::pair_t::xread_activated (pipe_t *pipe_)
......
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