From ef91a3baddc352a313995c90bf79c9a9aedd2f63 Mon Sep 17 00:00:00 2001 From: Sven Czarnian Date: Thu, 9 Dec 2021 12:29:24 +0100 Subject: [PATCH] cleanup internal structures as soon as the controller is disconnected --- src/PlugIn.cpp | 17 +++++++++++++++++ src/PlugIn.h | 1 + 2 files changed, 18 insertions(+) diff --git a/src/PlugIn.cpp b/src/PlugIn.cpp index 5959ce4..3fa825e 100644 --- a/src/PlugIn.cpp +++ b/src/PlugIn.cpp @@ -56,6 +56,7 @@ PlugIn::PlugIn() : m_inbounds(), m_forcedToBackendCallsigns(), m_compatible(false), + m_connectedToNetwork(false), m_sweatboxValid(false), m_playbackValid(false) { GOOGLE_PROTOBUF_VERIFY_VERSION; @@ -655,6 +656,22 @@ void PlugIn::updateSequence(std::shared_ptr& sequence) { } void PlugIn::OnTimer(int counter) { + /* cleanup the internal data */ + if (EuroScopePlugIn::CONNECTION_TYPE_NO == this->GetConnectionType()) { + if (true == this->m_connectedToNetwork) { + std::lock_guard guardUpdate(this->m_updateQueueLock); + this->m_updateQueue.clear(); + + std::lock_guard guardInbound(this->m_inboundsQueueLock); + this->m_inbounds.clear(); + + this->m_connectedToNetwork = false; + } + + return; + } + + this->m_connectedToNetwork = true; if (false == this->m_compatible || false == Backend::instance().initialized() || 0 != (counter % 10)) return; diff --git a/src/PlugIn.h b/src/PlugIn.h index fb52e1d..35f1741 100644 --- a/src/PlugIn.h +++ b/src/PlugIn.h @@ -61,6 +61,7 @@ namespace aman { std::map m_inbounds; std::list m_forcedToBackendCallsigns; bool m_compatible; + bool m_connectedToNetwork; bool m_sweatboxValid; bool m_playbackValid;