From 6635e28e3eb7cb49962ee667e573ff5495f73af7 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Tue, 6 Aug 2019 17:53:58 +0100 Subject: [PATCH] Fix segv deleting resume data, due to new VDR locking system --- jsonserver.c | 5 +++++ vdrclient.c | 11 +++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/jsonserver.c b/jsonserver.c index a725e33..38039fd 100644 --- a/jsonserver.c +++ b/jsonserver.c @@ -128,6 +128,11 @@ bool cPluginJsonserver::Start(void) try { logger = spd::basic_logger_mt("jsonserver_spdlog", cfgLogFilename); + if (!logger) + { + dsyslog("jsonserver: Failed to initialise log object - null"); + return false; + } } catch (const spd::spdlog_ex& ex) { diff --git a/vdrclient.c b/vdrclient.c index d441ea5..b1d2a8a 100644 --- a/vdrclient.c +++ b/vdrclient.c @@ -1291,12 +1291,16 @@ bool VDRClient::recresetresume(PFMap& postFields, Json::Value& js) // RETHROWS std::string reqfilename = getVarString(postFields, "filename"); logger->debug("recresetresume: {}", reqfilename); - LOCK_RECORDINGS_WRITE; // may not need write, but to be safe.. - cRecording *recording = Recordings->GetByName(reqfilename.c_str()); + cStateKey StateKey; + const cRecordings* Recordings = cRecordings::GetRecordingsRead(StateKey); + + const cRecording* recording = Recordings->GetByName(reqfilename.c_str()); if (!recording) { + StateKey.Remove(); + js["Result"] = false; js["Error"] = "Could not find recording to reset resume"; return true; @@ -1305,6 +1309,9 @@ bool VDRClient::recresetresume(PFMap& postFields, Json::Value& js) // RETHROWS logger->debug("recresetresume: Reset resume for: {}", recording->Name()); cResumeFile ResumeFile(recording->FileName(), recording->IsPesRecording()); + StateKey.Remove(); + + if (ResumeFile.Read() >= 0) { ResumeFile.Delete(); -- 2.39.5