From 2751e239eba118a319c1c8518fb199dc5d4114e4 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 28 May 2017 13:08:09 +0200 Subject: [PATCH] Fixed the locking sequence when dumping EPG data --- HISTORY | 1 + epg.c | 8 ++++---- epg.h | 4 ++-- svdrp.c | 6 +++--- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/HISTORY b/HISTORY index adb33c05..bcc6ddcf 100644 --- a/HISTORY +++ b/HISTORY @@ -9063,3 +9063,4 @@ Video Disk Recorder Revision History macro DEBUG_LOCKSEQ in thread.c. At the first occurrence of an invalid locking sequence, the 20 most recent locks will be printed to stderr, followed by a backtrace that led to the call in question. +- Fixed the locking sequence when dumping EPG data. diff --git a/epg.c b/epg.c index 3955d702..486844e5 100644 --- a/epg.c +++ b/epg.c @@ -7,7 +7,7 @@ * Original version (as used in VDR before 1.3.0) written by * Robert Schneider and Rolf Hakenes . * - * $Id: epg.c 4.7 2017/05/28 11:30:32 kls Exp $ + * $Id: epg.c 4.8 2017/05/28 13:08:09 kls Exp $ */ #include "epg.h" @@ -1104,9 +1104,8 @@ void cSchedule::Cleanup(time_t Time) } } -void cSchedule::Dump(FILE *f, const char *Prefix, eDumpMode DumpMode, time_t AtTime) const +void cSchedule::Dump(const cChannels *Channels, FILE *f, const char *Prefix, eDumpMode DumpMode, time_t AtTime) const { - LOCK_CHANNELS_READ; if (const cChannel *Channel = Channels->GetByChannelID(channelID, true)) { fprintf(f, "%sC %s %s\n", Prefix, *Channel->GetChannelID().ToString(), Channel->Name()); const cEvent *p; @@ -1280,9 +1279,10 @@ bool cSchedules::Dump(FILE *f, const char *Prefix, eDumpMode DumpMode, time_t At return false; } } + LOCK_CHANNELS_READ; LOCK_SCHEDULES_READ; for (const cSchedule *p = Schedules->First(); p; p = Schedules->Next(p)) - p->Dump(f, Prefix, DumpMode, AtTime); + p->Dump(Channels, f, Prefix, DumpMode, AtTime); if (sf) { sf->Close(); delete sf; diff --git a/epg.h b/epg.h index fe536a7d..6c422055 100644 --- a/epg.h +++ b/epg.h @@ -7,7 +7,7 @@ * Original version (as used in VDR before 1.3.0) written by * Robert Schneider and Rolf Hakenes . * - * $Id: epg.h 4.6 2017/05/09 12:15:14 kls Exp $ + * $Id: epg.h 4.7 2017/05/28 12:59:20 kls Exp $ */ #ifndef __EPG_H @@ -185,7 +185,7 @@ public: const cEvent *GetFollowingEvent(void) const; const cEvent *GetEvent(tEventID EventID, time_t StartTime = 0) const; const cEvent *GetEventAround(time_t Time) const; - void Dump(FILE *f, const char *Prefix = "", eDumpMode DumpMode = dmAll, time_t AtTime = 0) const; + void Dump(const cChannels *Channels, FILE *f, const char *Prefix = "", eDumpMode DumpMode = dmAll, time_t AtTime = 0) const; static bool Read(FILE *f, cSchedules *Schedules); }; diff --git a/svdrp.c b/svdrp.c index f402c21a..9caf6edf 100644 --- a/svdrp.c +++ b/svdrp.c @@ -10,7 +10,7 @@ * and interact with the Video Disk Recorder - or write a full featured * graphical interface that sits on top of an SVDRP connection. * - * $Id: svdrp.c 4.18 2017/05/18 15:51:24 kls Exp $ + * $Id: svdrp.c 4.19 2017/05/28 13:05:23 kls Exp $ */ #include "svdrp.h" @@ -1615,6 +1615,7 @@ void cSVDRPServer::CmdLSTC(const char *Option) void cSVDRPServer::CmdLSTE(const char *Option) { + LOCK_CHANNELS_READ; LOCK_SCHEDULES_READ; const cSchedule* Schedule = NULL; eDumpMode DumpMode = dmAll; @@ -1646,7 +1647,6 @@ void cSVDRPServer::CmdLSTE(const char *Option) } } else if (!Schedule) { - LOCK_CHANNELS_READ; const cChannel* Channel = NULL; if (isnumber(p)) Channel = Channels->GetByNumber(strtol(Option, NULL, 10)); @@ -1676,7 +1676,7 @@ void cSVDRPServer::CmdLSTE(const char *Option) FILE *f = fdopen(fd, "w"); if (f) { if (Schedule) - Schedule->Dump(f, "215-", DumpMode, AtTime); + Schedule->Dump(Channels, f, "215-", DumpMode, AtTime); else Schedules->Dump(f, "215-", DumpMode, AtTime); fflush(f);