[bug] Shutdown during an active timer is broken

Message ID 44CC8EF1.60108@cadsoft.de
State New
Headers

Commit Message

Klaus Schmidinger July 30, 2006, 10:50 a.m. UTC
  Klaus Schmidinger wrote:
> 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
> continued.
> 
> Please try the attached patch.

I just realized that a Next and Delta of '0' has special meaning to
the shutdown script, so here's another version of this patch, taking
into account if there is a 'timer' at all.

Klaus
  

Comments

Udo Richter July 30, 2006, 11:50 p.m. UTC | #1
Klaus Schmidinger wrote:
>> Please try the attached patch.

Did some simple tests, seems ok so far.

One thing remains: After "Recording - shut down anyway?", we should not 
ask "Recording in x minutes, shut down anyway?", as the 'next' recording 
is always the currently running one, and x is a negative value. The real 
next recording is unknown in this situation.

Cheers,

Udo
  

Patch

--- vdr.c	2006/06/18 08:49:20	1.276
+++ vdr.c	2006/07/30 10:47:50
@@ -1166,6 +1166,12 @@ 
                     else
                        LastActivity = 1;
                     }
+                 if (timer && 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)