From c60d14e39aa436c4f48d7b7ebbc1d31fee4f8bfd Mon Sep 17 00:00:00 2001 From: Jasmin Jessich Date: Wed, 7 Jun 2017 00:24:12 +0200 Subject: Fixed lock order in multischedule.ecpp and schedule.ecpp - Move the lockings into some blocks and execute other modules with unlocked Channels and Schedules lists. This might not perfect, but there is currently no other solution possible. --- pages/multischedule.ecpp | 29 +++++++++++++++++------------ pages/schedule.ecpp | 18 +++++++++++------- 2 files changed, 28 insertions(+), 19 deletions(-) (limited to 'pages') diff --git a/pages/multischedule.ecpp b/pages/multischedule.ecpp index 22a3f07..e82942b 100644 --- a/pages/multischedule.ecpp +++ b/pages/multischedule.ecpp @@ -46,9 +46,7 @@ std::vector times_start; if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html"); pageTitle = tr("MultiSchedule"); -#if VDRVERSNUM >= 20301 - LOCK_CHANNELS_READ; -#else +#if VDRVERSNUM < 20301 ReadLock channelsLock( Channels ); if ( !channelsLock ) throw HtmlError( tr("Couldn't aquire access to channels, please try again later.") ); @@ -62,6 +60,9 @@ std::vector times_start; if ( ( channel_groups_setting.compare(LiveSetup().GetChannelGroups()) != 0 ) || ( channel_groups_numbers.size() == 0 ) ) { +#if VDRVERSNUM >= 20301 + LOCK_CHANNELS_READ; +#endif // build the groups of channels to display std::string channelGroups=LiveSetup().GetChannelGroups(); if ( channelGroups.empty() ) @@ -271,9 +272,7 @@ std::vector times_start; <& menu active=("multischedule") component=("multischedule.channel_selection") &>
<%cpp> -#if VDRVERSNUM >= 20301 - LOCK_SCHEDULES_READ; -#else +#if VDRVERSNUM < 20301 cSchedulesLock schedulesLock; cSchedules const* schedules = cSchedules::Schedules( schedulesLock ); #endif @@ -305,14 +304,16 @@ std::vector times_start; for ( unsigned int j = 0; j= 20301 - cChannel* Channel = (cChannel *)Channels->GetByNumber( chan ); + { + LOCK_CHANNELS_READ; + Channel = (cChannel *)Channels->GetByNumber( chan ); + } #else - cChannel* Channel = Channels.GetByNumber( chan ); + Channel = Channels.GetByNumber( chan ); #endif if ( ! Channel ) continue; @@ -321,10 +322,14 @@ std::vector times_start; channel_names[ j ] = Channel->Name(); channel_IDs[ j ] = Channel->GetChannelID(); + cSchedule const* Schedule; #if VDRVERSNUM >= 20301 - cSchedule const* Schedule = Schedules->GetSchedule( (cChannel *)Channel ); + { + LOCK_SCHEDULES_READ; + Schedule = Schedules->GetSchedule( Channel ); + } #else - cSchedule const* Schedule = schedules->GetSchedule( Channel ); + Schedule = schedules->GetSchedule( Channel ); #endif if ( ! Schedule ) continue; diff --git a/pages/schedule.ecpp b/pages/schedule.ecpp index 71b62a0..7321f3c 100644 --- a/pages/schedule.ecpp +++ b/pages/schedule.ecpp @@ -25,10 +25,7 @@ if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html"); <%cpp> pageTitle = trVDR("Schedule"); -#if VDRVERSNUM >= 20301 - // we lock here only the channels on purpose - LOCK_CHANNELS_READ; -#else +#if VDRVERSNUM < 20301 cSchedulesLock schedulesLock; cSchedules const* schedules = cSchedules::Schedules( schedulesLock ); @@ -40,12 +37,16 @@ if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html"); // cChannel* Channel; (see %request above) if ( channel > 0 ) { #if VDRVERSNUM >= 20301 + LOCK_CHANNELS_READ; Channel = (cChannel *)Channels->GetByNumber( channel ); #else Channel = Channels.GetByNumber( channel ); #endif } else { +#if VDRVERSNUM >= 20301 + LOCK_CHANNELS_READ; +#endif if (cDevice::CurrentChannel()) { #if VDRVERSNUM >= 20301 Channel = (cChannel *)Channels->GetByNumber(cDevice::CurrentChannel()); @@ -64,11 +65,14 @@ if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html"); if ( Channel == 0 ) throw HtmlError( tr("Couldn't find channel or no channels available. Maybe you mistyped your request?") ); + cSchedule const* Schedule; #if VDRVERSNUM >= 20301 - LOCK_SCHEDULES_READ; - cSchedule const* Schedule = Schedules->GetSchedule( (const cChannel *)Channel ); + { + LOCK_SCHEDULES_READ; + Schedule = Schedules->GetSchedule( (const cChannel *)Channel ); + } #else - cSchedule const* Schedule = schedules->GetSchedule( Channel ); + Schedule = schedules->GetSchedule( Channel ); #endif <& pageelems.doc_type &> -- cgit v1.2.3