Implemented strict locking of global lists

This commit is contained in:
Klaus Schmidinger
2015-09-01 11:14:27 +02:00
parent 8a7bc6a0bb
commit 3cd5294d8a
41 changed files with 3512 additions and 2402 deletions

View File

@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: eitscan.c 2.7 2012/04/07 14:39:28 kls Exp $
* $Id: eitscan.c 4.1 2015/07/18 10:16:51 kls Exp $
*/
#include "eitscan.h"
@@ -45,13 +45,13 @@ int cScanData::Compare(const cListObject &ListObject) const
class cScanList : public cList<cScanData> {
public:
void AddTransponders(cList<cChannel> *Channels);
void AddTransponders(const cList<cChannel> *Channels);
void AddTransponder(const cChannel *Channel);
};
void cScanList::AddTransponders(cList<cChannel> *Channels)
void cScanList::AddTransponders(const cList<cChannel> *Channels)
{
for (cChannel *ch = Channels->First(); ch; ch = Channels->Next(ch))
for (const cChannel *ch = Channels->First(); ch; ch = Channels->Next(ch))
AddTransponder(ch);
Sort();
}
@@ -118,7 +118,8 @@ void cEITScanner::ForceScan(void)
void cEITScanner::Activity(void)
{
if (currentChannel) {
Channels.SwitchTo(currentChannel);
LOCK_CHANNELS_READ;
Channels->SwitchTo(currentChannel);
currentChannel = 0;
}
lastActivity = time(NULL);
@@ -129,7 +130,8 @@ void cEITScanner::Process(void)
if (Setup.EPGScanTimeout || !lastActivity) { // !lastActivity means a scan was forced
time_t now = time(NULL);
if (now - lastScan > ScanTimeout && now - lastActivity > ActivityTimeout) {
if (Channels.Lock(false, 10)) {
cStateKey StateKey;
if (const cChannels *Channels = cChannels::GetChannelsRead(StateKey, 10)) {
if (!scanList) {
scanList = new cScanList;
if (transponderList) {
@@ -137,7 +139,7 @@ void cEITScanner::Process(void)
delete transponderList;
transponderList = NULL;
}
scanList->AddTransponders(&Channels);
scanList->AddTransponders(Channels);
}
bool AnyDeviceSwitched = false;
for (int i = 0; i < cDevice::NumDevices(); i++) {
@@ -177,7 +179,7 @@ void cEITScanner::Process(void)
if (lastActivity == 0) // this was a triggered scan
Activity();
}
Channels.Unlock();
StateKey.Remove();
}
lastScan = time(NULL);
}