summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Hurton <hurtonm@gmail.com>2012-05-15 12:51:54 +0200
committerMartin Sustrik <sustrik@250bpm.com>2012-05-15 12:51:54 +0200
commitadbd29bfa16ae4d58c767d4b03e28841c7cd7fc5 (patch)
tree983f1c80ce406dc989a553c7580b84ba914410b0 /src
parent193f1e5208d782b7ee9f31922a908ecd80291cd5 (diff)
Do not crash when multiple peers connect to PAIR socket
When more then one peer connected to a PAIR socket, an application aborted due to assertion failure. This patch changes the PAIR socket behaviour so that it rejects any further connection requests.
Diffstat (limited to 'src')
-rw-r--r--src/pair.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/pair.cpp b/src/pair.cpp
index b4cb0b4..531bfc5 100644
--- a/src/pair.cpp
+++ b/src/pair.cpp
@@ -38,14 +38,20 @@ xs::pair_t::~pair_t ()
void xs::pair_t::xattach_pipe (pipe_t *pipe_, bool icanhasall_)
{
- xs_assert (!pipe);
- pipe = pipe_;
+ xs_assert (pipe_ != NULL);
+
+ // XS_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 xs::pair_t::xterminated (pipe_t *pipe_)
{
- xs_assert (pipe_ == pipe);
- pipe = NULL;
+ if (pipe_ == pipe)
+ pipe = NULL;
}
void xs::pair_t::xread_activated (pipe_t *pipe_)