From eda593934db9ccb1c67d566ecf13108672c08ab6 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Mon, 18 Feb 2013 10:41:43 +0100 Subject: [PATCH] Modified handling user inactivity in the shutdown handler to avoid a problem in case the system time is changed after VDR has been started --- CONTRIBUTORS | 4 ++++ HISTORY | 3 +++ config.h | 6 +++--- shutdown.c | 15 ++++++++++----- shutdown.h | 21 ++++++++++++--------- 5 files changed, 32 insertions(+), 17 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 2ede5a72..35d8c3d1 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1777,6 +1777,8 @@ Udo Richter for suggesting to shift editing marks that don't point to an I-frame towards the next I-frame when a recording is played for requesting to keep using relative paths when building plugins locally + for fixing a problem with detecting user inactivity in case the system time is + changed after VDR has been started Sven Kreiensen for his help in keeping 'channels.conf.terr' up to date @@ -3039,6 +3041,8 @@ S handling of PCR values for improving cutting MPEG-2 video for pointing out that FindHeader() can also be used in cMpeg2Fixer::AdjTref() + for reporting a problem with detecting user inactivity in case the system time is + changed after VDR has been started Peter Münster for fixing 'make install' to not overwrite existing configuration files diff --git a/HISTORY b/HISTORY index 42f5fde3..bba4882c 100644 --- a/HISTORY +++ b/HISTORY @@ -7649,3 +7649,6 @@ Video Disk Recorder Revision History - Updated the Finnish OSD texts (thanks to Rolf Ahrenberg). - Updated the Polish OSD texts (thanks to Marek Nazarko). +- Modified handling user inactivity in the shutdown handler to avoid a problem in case + the system time is changed after VDR has been started (thanks to Udo Richter, reported + by Sören Moch). diff --git a/config.h b/config.h index a41aa91d..a6ab9735 100644 --- a/config.h +++ b/config.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: config.h 2.68 2013/02/17 15:12:21 kls Exp $ + * $Id: config.h 2.69 2013/02/18 10:41:43 kls Exp $ */ #ifndef __CONFIG_H @@ -27,8 +27,8 @@ // The plugin API's version number: -#define APIVERSION "1.7.38" -#define APIVERSNUM 10738 // Version * 10000 + Major * 100 + Minor +#define APIVERSION "1.7.39" +#define APIVERSNUM 10739 // Version * 10000 + Major * 100 + Minor // When loading plugins, VDR searches them by their APIVERSION, which // may be smaller than VDRVERSION in case there have been no changes to diff --git a/shutdown.c b/shutdown.c index d71a3a13..445ed6f2 100644 --- a/shutdown.c +++ b/shutdown.c @@ -6,7 +6,7 @@ * * Original version written by Udo Richter . * - * $Id: shutdown.c 1.5 2008/02/24 10:29:00 kls Exp $ + * $Id: shutdown.c 2.1 2013/02/18 10:33:26 kls Exp $ */ #include "shutdown.h" @@ -117,7 +117,7 @@ void cShutdownHandler::CheckManualStart(int ManualStart) else { // Set inactive from now on dsyslog("scheduled wakeup time in %ld minutes, assuming automatic start of VDR", Delta / 60); - SetUserInactive(); + SetUserInactiveTimeout(-3, true); } } @@ -147,9 +147,14 @@ void cShutdownHandler::SetUserInactiveTimeout(int Seconds, bool Force) activeTimeout = 0; return; } - if (Seconds < 0) - Seconds = Setup.MinUserInactivity * 60; - activeTimeout = time(NULL) + Seconds; + if (Seconds >= 0) + activeTimeout = time(NULL) + Seconds; + else if (Seconds == -1) + activeTimeout = time(NULL) + Setup.MinUserInactivity * 60; + else if (Seconds == -2) + activeTimeout = 0; + else if (Seconds == -3) + activeTimeout = 1; } bool cShutdownHandler::ConfirmShutdown(bool Interactive) diff --git a/shutdown.h b/shutdown.h index 4dff8eab..bf2a2a42 100644 --- a/shutdown.h +++ b/shutdown.h @@ -6,7 +6,7 @@ * * Original version written by Udo Richter . * - * $Id: shutdown.h 1.1 2007/02/24 17:23:59 kls Exp $ + * $Id: shutdown.h 2.1 2013/02/18 10:35:27 kls Exp $ */ #ifndef __SHUTDOWN_H @@ -38,7 +38,7 @@ public: class cShutdownHandler { private: time_t activeTimeout; - ///< Time when VDR will become non-interactive. 0 means never. + ///< Time when VDR will become non-interactive. 0 means never, 1 means unknown time ago. time_t retry; ///< Time for retrying the shutdown. char *shutdownCommand; @@ -73,15 +73,18 @@ public: ///< Check whether VDR is in interactive mode or non-interactive mode (waiting for shutdown). ///< AtTime checks whether VDR will probably be inactive at that time. time_t GetUserInactiveTime(void) { return activeTimeout; } - ///< Time when user will become non-inactive, or 0 if never. + ///< Time when user will become non-inactive, or 0 if never, 1 if a long time ago void SetUserInactiveTimeout(int Seconds = -1, bool Force = false); - ///< Set the time when VDR will switch into non-interactive mode or power down. - ///< -1 means Setup.MinUserInactivity in the future. - ///< Otherwise, seconds in the future. - ///< If MinUserInactivity = 0 and Force = false, Seconds is ignored and VDR will - ///< stay interactive forever. + ///< Set the time in the future when VDR will switch into non-interactive mode or power down. + ///< Seconds >= 0 means that many seconds in the future. + ///< Seconds = -1 means Setup.MinUserInactivity in the future. + ///< Seconds = -2 means never. + ///< Seconds = -3 means a long, unknown time ago. + ///< Setup.MinUserInactivity = 0 will overrule this, unless Force = true is given. + ///< If Setup.MinUserInactivity = 0 and Force = false, Seconds is ignored and VDR will + ///< stay interactive forever (like Seconds = -2). void SetUserInactive(void) { SetUserInactiveTimeout(0, true); } - ///< Set VDR manually into non-interactive mode. + ///< Set VDR manually into non-interactive mode from now on. bool Retry(time_t AtTime = 0) { return retry <= (AtTime ? AtTime : time(NULL)); } ///< Check whether its time to re-try the shutdown. ///< AtTime checks whether VDR will probably be inactive at that time.