mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-14 11:06:59 +01:00
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.
This commit is contained in:
parent
16ec2868c5
commit
d84709497e
14
src/pair.cpp
14
src/pair.cpp
@ -38,14 +38,20 @@ zmq::pair_t::~pair_t ()
|
|||||||
|
|
||||||
void zmq::pair_t::xattach_pipe (pipe_t *pipe_, bool icanhasall_)
|
void zmq::pair_t::xattach_pipe (pipe_t *pipe_, bool icanhasall_)
|
||||||
{
|
{
|
||||||
zmq_assert (!pipe);
|
zmq_assert (pipe_ != NULL);
|
||||||
pipe = pipe_;
|
|
||||||
|
// 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_)
|
void zmq::pair_t::xterminated (pipe_t *pipe_)
|
||||||
{
|
{
|
||||||
zmq_assert (pipe_ == pipe);
|
if (pipe_ == pipe)
|
||||||
pipe = NULL;
|
pipe = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void zmq::pair_t::xread_activated (pipe_t *pipe_)
|
void zmq::pair_t::xread_activated (pipe_t *pipe_)
|
||||||
|
Loading…
Reference in New Issue
Block a user