From 4c0cbb0f1e6501061728a6bc3404889dfdf607be Mon Sep 17 00:00:00 2001 From: Alwin Esch Date: Sat, 15 Jan 2022 22:55:28 +0100 Subject: [PATCH 1/2] fix read errors during Kodi's start and connection restart The `kodi::addon::CInstancePVRClient::ConnectionStateChange` call has blocked process for few seconds and made problems if something else try to make works. By this change becomes on Kodi's start itself the `kodi::addon::CInstancePVRClient::ConnectionStateChange` called on addon start (if connection was successful). --- src/ClientInstance.cpp | 20 +++++++++++++------- src/ClientInstance.h | 1 + 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/ClientInstance.cpp b/src/ClientInstance.cpp index 56573617..154acb97 100644 --- a/src/ClientInstance.cpp +++ b/src/ClientInstance.cpp @@ -102,6 +102,8 @@ CVNSIClientInstance::~CVNSIClientInstance() m_running = false; if (m_thread.joinable()) m_thread.join(); + if (m_startInformThread.joinable()) + m_startInformThread.join(); Close(); } @@ -116,13 +118,15 @@ void CVNSIClientInstance::OnReconnect() { EnableStatusInterface(true, false); - kodi::addon::CInstancePVRClient::ConnectionStateChange("vnsi connection established", - PVR_CONNECTION_STATE_CONNECTED, - kodi::addon::GetLocalizedString(30045)); + m_startInformThread = std::thread([&]() { + kodi::addon::CInstancePVRClient::ConnectionStateChange("vnsi connection established", + PVR_CONNECTION_STATE_CONNECTED, + kodi::addon::GetLocalizedString(30045)); - kodi::addon::CInstancePVRClient::TriggerChannelUpdate(); - kodi::addon::CInstancePVRClient::TriggerTimerUpdate(); - kodi::addon::CInstancePVRClient::TriggerRecordingUpdate(); + kodi::addon::CInstancePVRClient::TriggerChannelUpdate(); + kodi::addon::CInstancePVRClient::TriggerTimerUpdate(); + kodi::addon::CInstancePVRClient::TriggerRecordingUpdate(); + }); } bool CVNSIClientInstance::Start(const std::string& hostname, @@ -1751,7 +1755,9 @@ std::unique_ptr CVNSIClientInstance::ReadResult(cRequestPacket* std::unique_lock lock(m_queue.m_mutex); if (cVNSISession::TransmitMessage(vrp) && - message.m_condition.wait_for(lock, std::chrono::milliseconds(CVNSISettings::Get().GetConnectTimeout() * 1000)) == std::cv_status::timeout) + message.m_condition.wait_for( + lock, std::chrono::seconds(CVNSISettings::Get().GetConnectTimeout())) == + std::cv_status::timeout) { kodi::Log(ADDON_LOG_ERROR, "%s - request timed out after %d seconds", __func__, CVNSISettings::Get().GetConnectTimeout()); diff --git a/src/ClientInstance.h b/src/ClientInstance.h index 00fba4d7..cd1c1709 100644 --- a/src/ClientInstance.h +++ b/src/ClientInstance.h @@ -174,4 +174,5 @@ class ATTR_DLL_LOCAL CVNSIClientInstance : public kodi::addon::CInstancePVRClien std::atomic m_running = {false}; std::thread m_thread; + std::thread m_startInformThread; }; From 95d949f0b04633bbe69cb2af44affdd779ee6893 Mon Sep 17 00:00:00 2001 From: Alwin Esch Date: Sat, 15 Jan 2022 21:54:17 +0100 Subject: [PATCH 2/2] increase version to 20.2.2 --- pvr.vdr.vnsi/addon.xml.in | 2 +- pvr.vdr.vnsi/changelog.txt | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pvr.vdr.vnsi/addon.xml.in b/pvr.vdr.vnsi/addon.xml.in index ded3c1d1..d0c1ad91 100644 --- a/pvr.vdr.vnsi/addon.xml.in +++ b/pvr.vdr.vnsi/addon.xml.in @@ -1,7 +1,7 @@ @ADDON_DEPENDS@ diff --git a/pvr.vdr.vnsi/changelog.txt b/pvr.vdr.vnsi/changelog.txt index 9eb9eaa9..506c3d74 100644 --- a/pvr.vdr.vnsi/changelog.txt +++ b/pvr.vdr.vnsi/changelog.txt @@ -1,3 +1,6 @@ +v20.2.2 +- Fix connection errors on Kodi start and during backend reconnections + v20.2.1 - Fix crash on some channels