summaryrefslogtreecommitdiffstats
path: root/Sluift
diff options
context:
space:
mode:
authorRoger Planas <roger.planas@isode.com>2018-10-12 10:29:17 (GMT)
committerRoger Planas <roger.planas@isode.com>2018-10-12 11:34:44 (GMT)
commit0f4a77303fedfaa57977d6ca528799305eac9367 (patch)
treed43816803c9a61ee3bae71cd9614a8522e76d313 /Sluift
parent66b60e9ac2ef9c12d22dcc31201e22e6eeb4804d (diff)
downloadswift-0f4a77303fedfaa57977d6ca528799305eac9367.zip
swift-0f4a77303fedfaa57977d6ca528799305eac9367.tar.bz2
Fix Component's disconnect to run event loop while isActive
The Component::disconnect() was controlling the running of the event loop with the isAvailable flag, but it turns out that depending on timing, a re-connect could be attempted and the component erroneously claim that the "Component is already connecting or connected", which could not possibly the case if the first attempt to connect the component failed (hence, not possible it was connected). By updating the event loop to use the correct isActive flag, this issue is fixed. This error was highlighted as a result of the previous commit "Prevent connect on active sluift clients and components". Also, the getNextEvent is fixed to do not suffer from the same problem, and use isActive instead of isAvailable. Test-information: Before the patch, a test that would attempt a second component connect after a failed one would randomly fail. After the patch, a test that would attempt a second component connect after a failed one has passed hundreds of time without failure. Change-Id: I20be6b1c8aec485ded3330c143dedd2161c4c66e
Diffstat (limited to 'Sluift')
-rw-r--r--Sluift/SluiftComponent.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/Sluift/SluiftComponent.cpp b/Sluift/SluiftComponent.cpp
index 126562e..ee09380 100644
--- a/Sluift/SluiftComponent.cpp
+++ b/Sluift/SluiftComponent.cpp
@@ -78,7 +78,7 @@ bool SluiftComponent::isConnected() const {
void SluiftComponent::disconnect() {
component->disconnect();
- while (component->isAvailable()) {
+ while (component->isActive()) {
eventLoop->runUntilEvents();
}
}
@@ -105,12 +105,12 @@ boost::optional<SluiftComponent::Event> SluiftComponent::getNextEvent(
}
// Wait for new events
- while (!watchdog.getTimedOut() && currentIndex >= pendingEvents.size() && component->isAvailable()) {
+ while (!watchdog.getTimedOut() && currentIndex >= pendingEvents.size() && component->isActive()) {
eventLoop->runUntilEvents();
}
// Finish if we're disconnected or timed out
- if (watchdog.getTimedOut() || !component->isAvailable()) {
+ if (watchdog.getTimedOut() || !component->isActive()) {
return boost::optional<Event>();
}
}