Added missing channel locking to cEIT

This commit is contained in:
Klaus Schmidinger 2012-03-14 10:41:48 +01:00
parent cd676fda36
commit c8b0ee3289
2 changed files with 13 additions and 11 deletions

View File

@ -7045,3 +7045,4 @@ Video Disk Recorder Revision History
- Fixed a memory leak in cSubtitleRegion::UpdateTextData(). - Fixed a memory leak in cSubtitleRegion::UpdateTextData().
- Moved setting LC_NUMERIC further up to make sure any floating point numbers use a - Moved setting LC_NUMERIC further up to make sure any floating point numbers use a
decimal point (suggested by Tobias Grimm). decimal point (suggested by Tobias Grimm).
- Added missing channel locking to cEIT.

23
eit.c
View File

@ -8,7 +8,7 @@
* Robert Schneider <Robert.Schneider@web.de> and Rolf Hakenes <hakenes@hippomi.de>. * Robert Schneider <Robert.Schneider@web.de> and Rolf Hakenes <hakenes@hippomi.de>.
* Adapted to 'libsi' for VDR 1.3.0 by Marcel Wiesweg <marcel.wiesweg@gmx.de>. * Adapted to 'libsi' for VDR 1.3.0 by Marcel Wiesweg <marcel.wiesweg@gmx.de>.
* *
* $Id: eit.c 2.15 2012/03/10 14:43:52 kls Exp $ * $Id: eit.c 2.16 2012/03/14 10:11:15 kls Exp $
*/ */
#include "eit.h" #include "eit.h"
@ -32,12 +32,18 @@ cEIT::cEIT(cSchedules *Schedules, int Source, u_char Tid, const u_char *Data, bo
if (!CheckCRCAndParse()) if (!CheckCRCAndParse())
return; return;
time_t Now = time(NULL);
if (Now < VALID_TIME)
return; // we need the current time for handling PDC descriptors
if (!Channels.Lock(false, 10))
return;
tChannelID channelID(Source, getOriginalNetworkId(), getTransportStreamId(), getServiceId()); tChannelID channelID(Source, getOriginalNetworkId(), getTransportStreamId(), getServiceId());
cChannel *channel = Channels.GetByChannelID(channelID, true); cChannel *channel = Channels.GetByChannelID(channelID, true);
if (!channel) if (!channel || EpgHandlers.IgnoreChannel(channel)) {
return; // only collect data for known channels Channels.Unlock();
if (EpgHandlers.IgnoreChannel(channel))
return; return;
}
cSchedule *pSchedule = (cSchedule *)Schedules->GetSchedule(channel, true); cSchedule *pSchedule = (cSchedule *)Schedules->GetSchedule(channel, true);
@ -45,13 +51,9 @@ cEIT::cEIT(cSchedules *Schedules, int Source, u_char Tid, const u_char *Data, bo
bool Modified = false; bool Modified = false;
time_t SegmentStart = 0; time_t SegmentStart = 0;
time_t SegmentEnd = 0; time_t SegmentEnd = 0;
time_t Now = time(NULL);
struct tm tm_r; struct tm tm_r;
struct tm t = *localtime_r(&Now, &tm_r); // this initializes the time zone in 't' struct tm t = *localtime_r(&Now, &tm_r); // this initializes the time zone in 't'
if (Now < VALID_TIME)
return; // we need the current time for handling PDC descriptors
SI::EIT::Event SiEitEvent; SI::EIT::Event SiEitEvent;
for (SI::Loop::Iterator it; eventLoop.getNext(SiEitEvent, it); ) { for (SI::Loop::Iterator it; eventLoop.getNext(SiEitEvent, it); ) {
if (EpgHandlers.HandleEitEvent(pSchedule, &SiEitEvent, Tid, getVersionNumber())) if (EpgHandlers.HandleEitEvent(pSchedule, &SiEitEvent, Tid, getVersionNumber()))
@ -295,13 +297,12 @@ cEIT::cEIT(cSchedules *Schedules, int Source, u_char Tid, const u_char *Data, bo
pSchedule->ClrRunningStatus(channel); pSchedule->ClrRunningStatus(channel);
pSchedule->SetPresentSeen(); pSchedule->SetPresentSeen();
} }
if (OnlyRunningStatus) if (Modified && !OnlyRunningStatus) {
return;
if (Modified) {
EpgHandlers.SortSchedule(pSchedule); EpgHandlers.SortSchedule(pSchedule);
EpgHandlers.DropOutdated(pSchedule, SegmentStart, SegmentEnd, Tid, getVersionNumber()); EpgHandlers.DropOutdated(pSchedule, SegmentStart, SegmentEnd, Tid, getVersionNumber());
Schedules->SetModified(pSchedule); Schedules->SetModified(pSchedule);
} }
Channels.Unlock();
} }
// --- cTDT ------------------------------------------------------------------ // --- cTDT ------------------------------------------------------------------