From c8b0ee3289849ab0d5778c58d65771f5c0270314 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Wed, 14 Mar 2012 10:41:48 +0100 Subject: [PATCH] Added missing channel locking to cEIT --- HISTORY | 1 + eit.c | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/HISTORY b/HISTORY index e4d8aac8..092d6efa 100644 --- a/HISTORY +++ b/HISTORY @@ -7045,3 +7045,4 @@ Video Disk Recorder Revision History - Fixed a memory leak in cSubtitleRegion::UpdateTextData(). - Moved setting LC_NUMERIC further up to make sure any floating point numbers use a decimal point (suggested by Tobias Grimm). +- Added missing channel locking to cEIT. diff --git a/eit.c b/eit.c index 1b8c84c4..cf64e89f 100644 --- a/eit.c +++ b/eit.c @@ -8,7 +8,7 @@ * Robert Schneider and Rolf Hakenes . * Adapted to 'libsi' for VDR 1.3.0 by Marcel Wiesweg . * - * $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" @@ -32,12 +32,18 @@ cEIT::cEIT(cSchedules *Schedules, int Source, u_char Tid, const u_char *Data, bo if (!CheckCRCAndParse()) 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()); cChannel *channel = Channels.GetByChannelID(channelID, true); - if (!channel) - return; // only collect data for known channels - if (EpgHandlers.IgnoreChannel(channel)) + if (!channel || EpgHandlers.IgnoreChannel(channel)) { + Channels.Unlock(); return; + } 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; time_t SegmentStart = 0; time_t SegmentEnd = 0; - time_t Now = time(NULL); struct tm tm_r; 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; for (SI::Loop::Iterator it; eventLoop.getNext(SiEitEvent, it); ) { 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->SetPresentSeen(); } - if (OnlyRunningStatus) - return; - if (Modified) { + if (Modified && !OnlyRunningStatus) { EpgHandlers.SortSchedule(pSchedule); EpgHandlers.DropOutdated(pSchedule, SegmentStart, SegmentEnd, Tid, getVersionNumber()); Schedules->SetModified(pSchedule); } + Channels.Unlock(); } // --- cTDT ------------------------------------------------------------------