summaryrefslogtreecommitdiffstats
path: root/Sluift
diff options
context:
space:
mode:
authorEdwin Mons <edwin.mons@isode.com>2018-10-04 13:52:48 (GMT)
committerEdwin Mons <edwin.mons@isode.com>2018-10-04 14:15:57 (GMT)
commit5d7ba3f76862cd561b295b79125a68dc4acf20df (patch)
tree46acf00fdf8ce0fbced86bb541e4830cba2e4e6c /Sluift
parentd0836aeb02594c322a9915041e4fe46077a91b7b (diff)
downloadswift-5d7ba3f76862cd561b295b79125a68dc4acf20df.zip
swift-5d7ba3f76862cd561b295b79125a68dc4acf20df.tar.bz2
Prevent connect on active sluift clients and components
Connect should not be called twice on clients or compoments without disconnecting first. While this worked in some cases, mixing connect options, specifically first trying without, and then with a bosh_url, would lead to asserts being triggered. The connect logic now checks whether there's already a connection in progress or established, and raises a Lua exception early if there is. Test-Information: Tested on macOS 10.13 Connected components and clients with invalid and valid hosts, and with valid and invalid bosh_urls, all with and without disconnecting in between attempts. No asserts were triggered, and appropriate Lua exceptions were thrown. Change-Id: I6b91b57945844bce7fce0073e5d0fe199ab815d5
Diffstat (limited to 'Sluift')
-rw-r--r--Sluift/SluiftClient.cpp5
-rw-r--r--Sluift/SluiftComponent.cpp5
2 files changed, 8 insertions, 2 deletions
diff --git a/Sluift/SluiftClient.cpp b/Sluift/SluiftClient.cpp
index e8c43c9..5243ed0 100644
--- a/Sluift/SluiftClient.cpp
+++ b/Sluift/SluiftClient.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2017 Isode Limited.
+ * Copyright (c) 2013-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -48,6 +48,9 @@ SluiftClient::~SluiftClient() {
}
void SluiftClient::connect() {
+ if (client->isActive()) {
+ throw Lua::Exception("Client is already connecting or connected");
+ }
rosterReceived = false;
blockListReceived = false;
disconnectedError = boost::optional<ClientError>();
diff --git a/Sluift/SluiftComponent.cpp b/Sluift/SluiftComponent.cpp
index e1d1738..126562e 100644
--- a/Sluift/SluiftComponent.cpp
+++ b/Sluift/SluiftComponent.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2016 Isode Limited.
+ * Copyright (c) 2014-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -41,6 +41,9 @@ SluiftComponent::~SluiftComponent() {
}
void SluiftComponent::connect(const std::string& host, int port) {
+ if (component->isActive()) {
+ throw Lua::Exception("Component is already connecting or connected");
+ }
disconnectedError = boost::optional<ComponentError>();
component->connect(host, port);
}