From b3a6214a190406ffcf4f1d74b0c7430b1ce71522 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 6 Nov 2011 14:44:26 +0000 Subject: [PATCH] zapit: fix deadlock after scan Depending on various race conditions, the scan thread would never terminate, or only after a connection timeout on the zapit socket. Fix by replacing CZapitClient calls with direct call of the reloadchannels command sequence. In general, using CZapitClient from within zapit seems not to be a good idea and deadlock prone. git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-beta@1832 e54a6e83-5905-42d5-8d5c-058d10e6a962 Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/4395d083d1e49c902081fd45a52138c2351485c4 Author: Stefan Seyfried Date: 2011-11-06 (Sun, 06 Nov 2011) --- src/zapit/src/scan.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/zapit/src/scan.cpp b/src/zapit/src/scan.cpp index 2a7050fcf..bcf85cc73 100644 --- a/src/zapit/src/scan.cpp +++ b/src/zapit/src/scan.cpp @@ -492,7 +492,7 @@ bool CServiceScan::ScanProviders() int scan_sat_mode = mode & 0xFF00; // single = 0, all = 1 printf("[zapit] scan mode %s, satellites %s\n", scan_nit ? "fast" : "NIT", scan_sat_mode ? "all" : "single"); - CZapitClient myZapitClient; + // CZapitClient myZapitClient; /* get first child */ //xmlNodePtr search = xmlDocGetRootElement(scanInputParser)->xmlChildrenNode; @@ -562,7 +562,16 @@ bool CServiceScan::ScanProviders() g_bouquetManager->loadBouquets(); printf("[scan] save bouquets done\n"); Cleanup(true); + /* this can hang as the thread handling the connections + * could already be in g_Zapit->stopScan(), waiting for + * *this* thread to join(). myZapitClient.reloadCurrentServices(); + * so let's do another ugly, layer-violating hack... + */ + CFrontend::getInstance()->setTsidOnid(0); + t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID(); + CZapit::getInstance()->ZapIt(live_channel_id, false); + CZapit::getInstance()->SendEvent(CZapitClient::EVT_SERVICES_CHANGED); } else { Cleanup(false); CFrontend::getInstance()->setTsidOnid(0); @@ -614,7 +623,7 @@ bool CServiceScan::ScanTransponder() if(abort_scan) found_channels = 0; - CZapitClient myZapitClient; + // CZapitClient myZapitClient; //FIXME move to Cleanup() ? if(found_channels) { CServiceManager::getInstance()->SaveServices(true); @@ -625,7 +634,13 @@ bool CServiceScan::ScanTransponder() //g_bouquetManager->clearAll(); g_bouquetManager->loadBouquets(); Cleanup(true); + /* see the explanation in CServiceScan::ScanProviders() in why this is a bad idea myZapitClient.reloadCurrentServices(); + */ + CFrontend::getInstance()->setTsidOnid(0); + t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID(); + CZapit::getInstance()->ZapIt(live_channel_id, false); + CZapit::getInstance()->SendEvent(CZapitClient::EVT_SERVICES_CHANGED); } else { Cleanup(false); CFrontend::getInstance()->setTsidOnid(0);