From fde4ca50a0f8887aec1ab17ab2fb368a2dcc71bd Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Mon, 20 Aug 2018 10:12:57 +0200 Subject: try to fix race conditions in 2.4. leave channel linking to VDR --- eepg.c | 10 +++++----- eit2.c | 54 +++++++++++++++++++++++++++++++++++++----------------- eit2.h | 10 +++++----- 3 files changed, 47 insertions(+), 27 deletions(-) diff --git a/eepg.c b/eepg.c index b319a46..f8ebb30 100644 --- a/eepg.c +++ b/eepg.c @@ -2917,7 +2917,7 @@ void cFilterEEPG::ProccessContinuous(u_short Pid, u_char Tid, int Length, const { //0x39 Viasat, 0x0300 Dish Network EEPG, 0x0441 Bell ExpressVU EEPG LogD(4, prep("Pid: 0x%02x Tid: %d Length: %d"), Pid, Tid, Length); -#if APIVERSNUM >= 20300 +/*#if APIVERSNUM >= 20300 LOCK_CHANNELS_WRITE; LOCK_SCHEDULES_WRITE; // cStateKey SchedulesStateKey; @@ -2925,12 +2925,12 @@ void cFilterEEPG::ProccessContinuous(u_short Pid, u_char Tid, int Length, const #else cSchedulesLock SchedulesLock(true, 10); cSchedules *Schedules = (cSchedules*)(cSchedules::Schedules(SchedulesLock)); -#endif +#endif*/ //Look for other satelite positions only if Dish/Bell ExpressVU for the moment hardcoded pid check - if(Channels && Schedules) - SI::cEIT2 EIT(Channels, Schedules, Source(), Tid, Data, Format, Pid == EIT_PID); + //if(Channels && Schedules) + SI::cEIT2 EIT(/*Channels, Schedules,*/ Source(), Tid, Data, Format, Pid == EIT_PID); -#if APIVERSNUM < 20300 +#if APIVERSNUM < 20300 //TODO else//cEIT EIT (Schedules, Source (), Tid, Data); { // If we don't get a write lock, let's at least get a read lock, so diff --git a/eit2.c b/eit2.c index a8b0561..cb5f9fc 100644 --- a/eit2.c +++ b/eit2.c @@ -18,7 +18,7 @@ using namespace util; namespace SI { -cEvent* cEIT2::ProcessEitEvent(cSchedule* pSchedule,const SI::EIT::Event* EitEvent, +cEvent* cEIT2::ProcessEitEvent(/*cChannels* Channels, cSchedules * Schedules,*/cSchedule* pSchedule,const SI::EIT::Event* EitEvent, uchar Tid, uchar versionNumber) { bool ExternalData = false; @@ -90,7 +90,7 @@ cEvent* cEIT2::ProcessEitEvent(cSchedule* pSchedule,const SI::EIT::Event* EitEve pEvent->SetVersion (versionNumber); ProcessEventDescriptors(ExternalData, channel->Source(), Tid, EitEvent, - pEvent, Schedules, channel->GetChannelID()); + pEvent, /*Schedules,*/ channel->GetChannelID()); Modified = true; return pEvent; @@ -98,10 +98,10 @@ cEvent* cEIT2::ProcessEitEvent(cSchedule* pSchedule,const SI::EIT::Event* EitEve void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source, u_char Tid, const SI::EIT::Event* SiEitEvent, cEvent* pEvent, - cSchedules* Schedules, const tChannelID& channelId) + /*cChannels* Channels, cSchedules* Schedules,*/ const tChannelID& channelId) { - cEvent *rEvent = NULL; + const cEvent *rEvent = NULL; int LanguagePreferenceShort = -1; int LanguagePreferenceExt = -1; unsigned char nDescriptorTag; @@ -114,14 +114,14 @@ void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source, //uchar DishTheme = 0, DishCategory = 0; - cLinkChannels *LinkChannels = NULL; + //cLinkChannels *LinkChannels = NULL; cComponents *Components = NULL; -#if APIVERSNUM >= 20300 +/*#if APIVERSNUM >= 20300 cChannel *channel = Channels->GetByChannelID(channelId); #else cChannel *channel = Channels.GetByChannelID(channelId); -#endif +#endif*/ DescriptorLoop dl = SiEitEvent->eventDescriptors; for (SI::Loop::Iterator it2; (d = dl.getNext(it2)); ) @@ -232,13 +232,18 @@ void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source, } break; case SI::TimeShiftedEventDescriptorTag: { +#if APIVERSNUM >= 20300 + LOCK_SCHEDULES_READ; +#else + //TODO +#endif if (Schedules) { SI::TimeShiftedEventDescriptor * tsed = (SI::TimeShiftedEventDescriptor *) d; - cSchedule *rSchedule = (cSchedule *) Schedules->GetSchedule( + const cSchedule *rSchedule = Schedules->GetSchedule( tChannelID(Source, channel->Nid(), channel->Tid(), tsed->getReferenceServiceId())); if (!rSchedule) break; - rEvent = (cEvent *) rSchedule->GetEvent(tsed->getReferenceEventId()); + rEvent = rSchedule->GetEvent(tsed->getReferenceEventId()); if (!rEvent) break; pEvent->SetTitle(rEvent->Title()); @@ -248,7 +253,8 @@ void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source, } break; case SI::LinkageDescriptorTag: { - SI::LinkageDescriptor * ld = (SI::LinkageDescriptor *) d; + //Leave channel linking to VDR +/* SI::LinkageDescriptor * ld = (SI::LinkageDescriptor *) d; tChannelID linkID(Source, ld->getOriginalNetworkId(), ld->getTransportStreamId(), ld->getServiceId()); if (ld->getLinkageType() == 0xB0) { // Premiere World @@ -290,7 +296,7 @@ void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source, else channel->SetPortalName(linkName); } - } + }*/ } break; case SI::ComponentDescriptorTag: { @@ -455,15 +461,15 @@ void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source, if (Format != DISH_BEV) pEvent->FixEpgBugs(); - if (LinkChannels) - channel->SetLinkChannels (LinkChannels); + //if (LinkChannels) + //channel->SetLinkChannels (LinkChannels); } -cEIT2::cEIT2 (cChannels* Channels, cSchedules * Schedules, int Source, u_char Tid, const u_char * Data, EFormat format, bool isEITPid, bool OnlyRunningStatus) +cEIT2::cEIT2 (/*cChannels* Channels, cSchedules * Schedules,*/ int Source, u_char Tid, const u_char * Data, EFormat format, bool isEITPid, bool OnlyRunningStatus) : SI::EIT (Data, false) , OnlyRunningStatus(OnlyRunningStatus) -, Channels(Channels) -, Schedules(Schedules) +//, Channels(Channels) +//, Schedules(Schedules) , Format(format) { @@ -486,6 +492,20 @@ cEIT2::cEIT2 (cChannels* Channels, cSchedules * Schedules, int Source, u_char Ti //LogD(5, prep("channelID: %s format:%d"), *channel->GetChannelID().ToString(), Format); +#if APIVERSNUM >= 20300 + LOCK_CHANNELS_WRITE; + if (!Channels) { + LogD(3, prep("Error obtaining channels lock")); + return; + } + LOCK_SCHEDULES_WRITE; + if (!Schedules) { + LogD(3, prep("Error obtaining schedules lock")); + return; + } +#else + //TODO +#endif cSchedule *pSchedule = (cSchedule *) Schedules->GetSchedule (channel, true); Empty = true; @@ -602,7 +622,7 @@ cEIT2::cEIT2 (cSchedule * Schedule, EFormat format) , OnlyRunningStatus(false) , SegmentStart(0) , SegmentEnd(0) -, Schedules(NULL) +//, Schedules(NULL) , Format(format) { //LogD(2, prep("cEIT2::cEIT2")); diff --git a/eit2.h b/eit2.h index 65d4b82..2e086d6 100644 --- a/eit2.h +++ b/eit2.h @@ -51,18 +51,18 @@ extern bool SystemCharacterTableIsSingleByte;*/ class cEIT2:public SI::EIT { public: - cEIT2(cChannels* Channels, cSchedules * Schedules, int Source, u_char Tid, const u_char * Data, + cEIT2(/*cChannels* Channels, cSchedules * Schedules,*/ int Source, u_char Tid, const u_char * Data, EFormat format, bool isEITPid = false, bool OnlyRunningStatus = false); cEIT2 (cSchedule * Schedule, EFormat format); //protected: // void updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEvent *pEvent); - cEvent* ProcessEitEvent(cSchedule *Schedule, const SI::EIT::Event *EitEvent, uchar TableID, uchar Version); + cEvent* ProcessEitEvent(/*cChannels* Channels, cSchedules * Schedules,*/cSchedule *Schedule, const SI::EIT::Event *EitEvent, uchar TableID, uchar Version); private: void ProcessEventDescriptors(bool ExternalData, int Source, u_char Tid, const SI::EIT::Event* SiEitEvent, cEvent* pEvent, - cSchedules* Schedules, const tChannelID& channelID); + /*cChannels* Channels,cSchedules* Schedules,*/ const tChannelID& channelID); private: bool Empty; @@ -71,8 +71,8 @@ private: bool OnlyRunningStatus; time_t SegmentStart; time_t SegmentEnd; - cChannels* Channels; - cSchedules* Schedules; +// cChannels* Channels; +// cSchedules* Schedules; EFormat Format; const cChannel* channel; }; -- cgit v1.2.3 From 27fbd9ec01e5fc69f83a0649a631223b655b3a7a Mon Sep 17 00:00:00 2001 From: Dimitar Petrovski Date: Tue, 21 Aug 2018 10:33:02 +0200 Subject: code clenaup --- eepg.c | 30 +----------------------------- eit2.c | 62 ++++++++++++++++++++++++++++++++++++++++---------------------- eit2.h | 10 +++------- 3 files changed, 44 insertions(+), 58 deletions(-) diff --git a/eepg.c b/eepg.c index f8ebb30..ebcd745 100644 --- a/eepg.c +++ b/eepg.c @@ -2917,36 +2917,8 @@ void cFilterEEPG::ProccessContinuous(u_short Pid, u_char Tid, int Length, const { //0x39 Viasat, 0x0300 Dish Network EEPG, 0x0441 Bell ExpressVU EEPG LogD(4, prep("Pid: 0x%02x Tid: %d Length: %d"), Pid, Tid, Length); -/*#if APIVERSNUM >= 20300 - LOCK_CHANNELS_WRITE; - LOCK_SCHEDULES_WRITE; -// cStateKey SchedulesStateKey; -// cSchedules *Schedules = cSchedules::GetSchedulesWrite(SchedulesStateKey, 10); -#else - cSchedulesLock SchedulesLock(true, 10); - cSchedules *Schedules = (cSchedules*)(cSchedules::Schedules(SchedulesLock)); -#endif*/ //Look for other satelite positions only if Dish/Bell ExpressVU for the moment hardcoded pid check - //if(Channels && Schedules) - SI::cEIT2 EIT(/*Channels, Schedules,*/ Source(), Tid, Data, Format, Pid == EIT_PID); - -#if APIVERSNUM < 20300 //TODO - else//cEIT EIT (Schedules, Source (), Tid, Data); - { - // If we don't get a write lock, let's at least get a read lock, so - // that we can set the running status and 'seen' timestamp (well, actually - // with a read lock we shouldn't be doing that, but it's only integers that - // get changed, so it should be ok) - cChannelsLock ChannelsLock; - cChannels *Channels = (cSchedules*)(cSchedules::Schedules(SchedulesLock)); - cSchedulesLock SchedulesLock; - cSchedules *Schedules = (cSchedules*)(cSchedules::Schedules(SchedulesLock)); - if(Channels && Schedules) - SI::cEIT2 EIT(Channels, Schedules, Source(), Tid, Data, Format, Pid == EIT_PID, true); - - //cEIT EIT (Schedules, Source (), Tid, Data, true); - } -#endif + SI::cEIT2 EIT(Source(), Tid, Data, Format, Pid == EIT_PID); } void cFilterEEPG::Process (u_short Pid, u_char Tid, const u_char * Data, int Length) diff --git a/eit2.c b/eit2.c index cb5f9fc..5aeb60d 100644 --- a/eit2.c +++ b/eit2.c @@ -18,7 +18,7 @@ using namespace util; namespace SI { -cEvent* cEIT2::ProcessEitEvent(/*cChannels* Channels, cSchedules * Schedules,*/cSchedule* pSchedule,const SI::EIT::Event* EitEvent, +cEvent* cEIT2::ProcessEitEvent(cSchedule* pSchedule,const SI::EIT::Event* EitEvent, uchar Tid, uchar versionNumber) { bool ExternalData = false; @@ -90,15 +90,14 @@ cEvent* cEIT2::ProcessEitEvent(/*cChannels* Channels, cSchedules * Schedules,*/c pEvent->SetVersion (versionNumber); ProcessEventDescriptors(ExternalData, channel->Source(), Tid, EitEvent, - pEvent, /*Schedules,*/ channel->GetChannelID()); + pEvent, channel->GetChannelID()); Modified = true; return pEvent; } -void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source, - u_char Tid, const SI::EIT::Event* SiEitEvent, cEvent* pEvent, - /*cChannels* Channels, cSchedules* Schedules,*/ const tChannelID& channelId) +void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source, u_char Tid, + const SI::EIT::Event* SiEitEvent, cEvent* pEvent, const tChannelID& channelId) { const cEvent *rEvent = NULL; @@ -235,7 +234,8 @@ void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source, #if APIVERSNUM >= 20300 LOCK_SCHEDULES_READ; #else - //TODO + cSchedulesLock SchedulesLock; + cSchedules *Schedules = (cSchedules*)(cSchedules::Schedules(SchedulesLock)); #endif if (Schedules) { SI::TimeShiftedEventDescriptor * tsed = (SI::TimeShiftedEventDescriptor *) d; @@ -465,11 +465,9 @@ void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source, //channel->SetLinkChannels (LinkChannels); } -cEIT2::cEIT2 (/*cChannels* Channels, cSchedules * Schedules,*/ int Source, u_char Tid, const u_char * Data, EFormat format, bool isEITPid, bool OnlyRunningStatus) +cEIT2::cEIT2 (int Source, u_char Tid, const u_char * Data, EFormat format, bool isEITPid) : SI::EIT (Data, false) -, OnlyRunningStatus(OnlyRunningStatus) -//, Channels(Channels) -//, Schedules(Schedules) +, OnlyRunningStatus(false) , Format(format) { @@ -493,18 +491,39 @@ cEIT2::cEIT2 (/*cChannels* Channels, cSchedules * Schedules,*/ int Source, u_cha //LogD(5, prep("channelID: %s format:%d"), *channel->GetChannelID().ToString(), Format); #if APIVERSNUM >= 20300 - LOCK_CHANNELS_WRITE; - if (!Channels) { - LogD(3, prep("Error obtaining channels lock")); - return; - } - LOCK_SCHEDULES_WRITE; - if (!Schedules) { - LogD(3, prep("Error obtaining schedules lock")); - return; - } + LOCK_CHANNELS_WRITE; + if (!Channels) { + LogD(3, prep("Error obtaining channels lock")); + return; + } + LOCK_SCHEDULES_WRITE; + if (!Schedules) { + LogD(3, prep("Error obtaining schedules lock")); + return; + } #else - //TODO + cChannelsLock ChannelsLock(true, 10), ChannelsLockR; + cChannels *Channels = (cChannels*)(cChannels::Channels(ChannelsLock)); + cSchedulesLock SchedulesLock(true, 10), SchedulesLockR; + cSchedules *Schedules = (cSchedules*)(cSchedules::Schedules(SchedulesLock)); + if (!Channels) { + LogD(3, prep("Error obtaining channels lock")); + OnlyRunningStatus = true; + cChannels *Channels = (cChannels*)(cChannels::Channels(ChannelsLockR)); + } + if (!Schedules) { + // If we don't get a write lock, let's at least get a read lock, so + // that we can set the running status and 'seen' timestamp (well, actually + // with a read lock we shouldn't be doing that, but it's only integers that + // get changed, so it should be ok) + LogD(3, prep("Error obtaining schedules lock")); + OnlyRunningStatus = true; + cSchedules *Schedules = (cSchedules*)(cSchedules::Schedules(SchedulesLockR)); + } + if (!Schedules || !Channels) { + LogD(3, prep("Error obtaining read lock")); + return; + } #endif cSchedule *pSchedule = (cSchedule *) Schedules->GetSchedule (channel, true); @@ -622,7 +641,6 @@ cEIT2::cEIT2 (cSchedule * Schedule, EFormat format) , OnlyRunningStatus(false) , SegmentStart(0) , SegmentEnd(0) -//, Schedules(NULL) , Format(format) { //LogD(2, prep("cEIT2::cEIT2")); diff --git a/eit2.h b/eit2.h index 2e086d6..9a46e7c 100644 --- a/eit2.h +++ b/eit2.h @@ -51,18 +51,16 @@ extern bool SystemCharacterTableIsSingleByte;*/ class cEIT2:public SI::EIT { public: - cEIT2(/*cChannels* Channels, cSchedules * Schedules,*/ int Source, u_char Tid, const u_char * Data, - EFormat format, bool isEITPid = false, - bool OnlyRunningStatus = false); + cEIT2 (int Source, u_char Tid, const u_char * Data, EFormat format, bool isEITPid = false); cEIT2 (cSchedule * Schedule, EFormat format); //protected: // void updateEquivalent(cSchedules * Schedules, tChannelID channelID, cEvent *pEvent); - cEvent* ProcessEitEvent(/*cChannels* Channels, cSchedules * Schedules,*/cSchedule *Schedule, const SI::EIT::Event *EitEvent, uchar TableID, uchar Version); + cEvent* ProcessEitEvent(cSchedule *Schedule, const SI::EIT::Event *EitEvent, uchar TableID, uchar Version); private: void ProcessEventDescriptors(bool ExternalData, int Source, u_char Tid, const SI::EIT::Event* SiEitEvent, cEvent* pEvent, - /*cChannels* Channels,cSchedules* Schedules,*/ const tChannelID& channelID); + const tChannelID& channelID); private: bool Empty; @@ -71,8 +69,6 @@ private: bool OnlyRunningStatus; time_t SegmentStart; time_t SegmentEnd; -// cChannels* Channels; -// cSchedules* Schedules; EFormat Format; const cChannel* channel; }; -- cgit v1.2.3