Force VDR to save channels.conf

Message ID 4FC211FB.4030108@iki.fi
State New
Headers

Commit Message

Anssi Hannula May 27, 2012, 11:37 a.m. UTC
  26.05.2012 23:54, Tobi kirjoitti:
> On 26.05.2012 20:56, Artem Makhutov wrote:
> 
>> How ever - when I restart VDR the changes are not getting saved to
>> channels.conf.
> 
> Check the syslog. There might be a plugin not cleanly shutting down,
> making the vdr abort it's shutdown sequence causing it's settings to not
> be saved.

Unless things have changed very recently, VDR doesn't save channels.conf
on shutdown.

It only saves it
a) Immediately after user manually modifies channels via VDR
b) 10 minutes after automatic channel update

I've been hit with this many times as well, so I'd suggest to change VDR
so that it saves automatic channel updates on exit as well. Suggested
patch attached (only compile-tested, so actual testing is needed).
  

Comments

Klaus Schmidinger June 2, 2012, 2:55 p.m. UTC | #1
On 27.05.2012 13:37, Anssi Hannula wrote:
> 26.05.2012 23:54, Tobi kirjoitti:
>> On 26.05.2012 20:56, Artem Makhutov wrote:
>>
>>> How ever - when I restart VDR the changes are not getting saved to
>>> channels.conf.
>>
>> Check the syslog. There might be a plugin not cleanly shutting down,
>> making the vdr abort it's shutdown sequence causing it's settings to not
>> be saved.
>
> Unless things have changed very recently, VDR doesn't save channels.conf
> on shutdown.
>
> It only saves it
> a) Immediately after user manually modifies channels via VDR
> b) 10 minutes after automatic channel update
>
> I've been hit with this many times as well, so I'd suggest to change VDR
> so that it saves automatic channel updates on exit as well. Suggested
> patch attached (only compile-tested, so actual testing is needed).

I'm afraid it's not that simple.

channels.conf and timers.conf must always be in sync, because timers
reference channels. Plus you need to have a lock on the Channels list
to prevent any changes from other threads while saving the list.
See the main VDR loop under "// Handle channel and timer modifications":

           if ((modified || timeout) && Channels.Lock(false, 100)) {
               if (timeout) {
                  Channels.Save();
                  Timers.Save();
                  ChannelSaveTimeout = 0;
                  }

Is it really that important to explicitly save automatic channel changes
when VDR stops? After all, they will be applied again next time VDR tunes
to those transponders...

Klaus
  

Patch

Index: vdr-1.7.26/vdr.c
===================================================================
--- vdr-1.7.26/vdr.c
+++ vdr-1.7.26/vdr.c	2012-05-27 14:32:06.886993810 +0300
@@ -1299,6 +1299,10 @@ 
      Setup.CurrentVolume  = cDevice::CurrentVolume();
      Setup.Save();
      }
+  if (Channels.Modified()) {
+     // Save any automatic channels.conf modifications
+     Channels.Save();
+     }
   cDevice::Shutdown();
   EpgHandlers.Clear();
   PluginManager.Shutdown(true);