diff --git a/CONTRIBUTORS b/CONTRIBUTORS index cfa61806..3fa1bda8 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -2477,6 +2477,7 @@ Christoph Haubrich for reporting a problem where the info file of an ongoing recording was not re-read for reporting that some channels change their video PID in the middle of a broadcast, which needs to be taken into account when regenerating the index of a recording + for reporting that shutdown needs to take into account the VPS margin Pekka Mauno for fixing cSchedule::GetFollowingEvent() in case there is currently no present diff --git a/HISTORY b/HISTORY index f594c8fd..4c1e8662 100644 --- a/HISTORY +++ b/HISTORY @@ -10172,3 +10172,4 @@ Video Disk Recorder Revision History - Now sending the SVDRP discover broadcast once per minute, to re-establish lost connections. - If an SVDRP peer connection is lost, the connection in the opposite direction is now also closed (reported by Markus Ehrnsperger). +- Shutdown now takes into account the VPS margin (reported by Christoph Haubrich). diff --git a/shutdown.c b/shutdown.c index 7e170a04..4ff00117 100644 --- a/shutdown.c +++ b/shutdown.c @@ -6,7 +6,7 @@ * * Original version written by Udo Richter . * - * $Id: shutdown.c 5.1 2022/11/22 14:33:48 kls Exp $ + * $Id: shutdown.c 5.2 2025/07/21 19:58:14 kls Exp $ */ #include "shutdown.h" @@ -90,6 +90,17 @@ cShutdownHandler::~cShutdownHandler() free(shutdownCommand); } +static time_t GetWakeupTime(const cTimer *Timer) +{ + if (Timer) { + time_t t = Timer->StartTime(); + if (Timer->HasFlags(tfVps)) + t -= Setup.VpsMargin; + return t; + } + return 0; +} + void cShutdownHandler::RequestEmergencyExit(void) { if (Setup.EmergencyExit) { @@ -170,9 +181,8 @@ bool cShutdownHandler::ConfirmShutdown(bool Interactive) } LOCK_TIMERS_READ; - const cTimer *Timer = Timers->GetNextActiveTimer(); - time_t Next = Timer ? Timer->StartTime() : 0; - time_t Delta = Timer ? Next - time(NULL) : 0; + time_t Next = GetWakeupTime(Timers->GetNextActiveTimer()); + time_t Delta = Next ? Next - time(NULL) : 0; if (cRecordControls::Active() || (Next && Delta <= 0)) { // VPS recordings in timer end margin may cause Delta <= 0 @@ -214,9 +224,8 @@ bool cShutdownHandler::ConfirmRestart(bool Interactive) } LOCK_TIMERS_READ; - const cTimer *Timer = Timers->GetNextActiveTimer(); - time_t Next = Timer ? Timer->StartTime() : 0; - time_t Delta = Timer ? Next - time(NULL) : 0; + time_t Next = GetWakeupTime(Timers->GetNextActiveTimer()); + time_t Delta = Next ? Next - time(NULL) : 0; if (cRecordControls::Active() || (Next && Delta <= 0)) { // VPS recordings in timer end margin may cause Delta <= 0 @@ -237,7 +246,7 @@ bool cShutdownHandler::DoShutdown(bool Force) const cTimer *Timer = Timers->GetNextActiveTimer(); cPlugin *Plugin = cPluginManager::GetNextWakeupPlugin(); - time_t Next = Timer ? Timer->StartTime() : 0; + time_t Next = GetWakeupTime(Timer); time_t NextPlugin = Plugin ? Plugin->WakeupTime() : 0; if (NextPlugin && (!Next || Next > NextPlugin)) { Next = NextPlugin;