[bug] Shutdown during an active timer is broken

Message ID 44CC762F.7010305@cadsoft.de
State New

Commit Message

Klaus Schmidinger July 30, 2006, 9:04 a.m. UTC
  Udo Richter wrote:
> Klaus Schmidinger wrote:
>> As a safety precaution, in case the user turned off VDR and ignored
>> all the warnings, let's just tell the shutdown script to reboot it
>> at, say, five minutes in the future (in case a recording is going on)
>> or whenever the next timer hits after that time.
> I'm not sure whether I like the idea that VDR starts again after 5 
> minutes, probably just in that moment when I am plugging a PCI card or 
> something like that. (Yes, you're *supposed* to pull the plug first. You 
> really do? ;) )
> Anyway, 5 mins is too short, anything less that 10 mins will be denied 
> by nvram-wakeup default configuration.

Well, then let's use Setup.MinEventTimeout. After all, the user has
confirmed that any onging recording as well as any timer starting
withing Setup.MinEventTimeout doesn't matter.

>> If the user doesn't want this to happen, then he/she can simply go
>> into the Timers menu and turn timers off as desired. 
> I don't have a problem with disabling the offending timers manually. I 
> just wrote the patch because of the request.

Sure, and I'm not critizising that. It just showed to me that if we
go down that road things will become ever more complex, and sure enough
somebody will come up with yet another level of complexity.

> Its just a bit strange that VDR requires extra confirmation, and then 
> nvram-wakeup denies shutdown anyway. (or other shoudown scrips doing 
> even more strange things)
> On a side note: With some scripting-fu, it should be possible to disable 
> the offending timers from the shutdown script via SVDRP, and then 
> request the new reboot time also via SVDRP.

My suggestion would be: as soon as ForceShutdown is set and Delta is
less than Setup.MinEventTimeout, let's just set Delta to Setup.MinEventTimeout
(and adjust Next accordingly). The worst that can happen is that VDR restarts
after half an hour (default for MinEventTimeout) and continues to do
whatever it takes. If the user turns it on earlier, all programmed timers
will still be there and even recordings that were interrupted will be

Please try the attached patch.



--- vdr.c	2006/06/18 08:49:20	1.276
+++ vdr.c	2006/07/30 09:02:50
@@ -1166,6 +1166,12 @@ 
                        LastActivity = 1;
+                 if (Delta < Setup.MinEventTimeout * 60 && ForceShutdown) {
+                    Delta = Setup.MinEventTimeout * 60;
+                    Next = Now + Delta;
+                    timer = NULL;
+                    dsyslog("reboot at %s", *TimeToString(Next));
+                    }
                  if (!Next || Delta > Setup.MinEventTimeout * 60 || ForceShutdown) {
                     ForceShutdown = false;
                     if (timer)