[mythtv-users] mythbackend idle timeout does not start

Leighton Brough brough at baremetalsoft.com
Tue Jul 31 11:34:22 UTC 2007

Gary Dawes wrote:
> On 30/07/07, *Gary Dawes* <gary.dawes at gmail.com 
> <mailto:gary.dawes at gmail.com>> wrote:
>     On 30/07/07, John Veness <John.Veness.myth at pelago.org.uk
>     <mailto:John.Veness.myth at pelago.org.uk>> wrote:
>     > Gary Dawes wrote:
>     > > Hi
>     > >
>     > > I managed to get the acpi shutdown & wakeup working without
>     too  much
>     > > difficulty, however I have a problem with the backend not
>     starting the
>     > > Idle countdown. Mythwelcome, reports that the backend is idle, but
>     > > nothing happens. If I restart the backend, it immeadiately
>     starts the
>     > > countdown, and then everything works as advertised.
>     > >
>     > > I have scoured the lists, checked my program schedules, ran
>     repairs on
>     > > the DB in case there was a problem there, and I'm now at a
>     dead end. I'm
>     > > running 0.20.20060828-3 (from the status page)  on knoppmyth
>     R5E50 if it
>     > > helps.
>     > >
>     > > Regards
>     > >
>     > > Gaz
>     >
>     > Are you shutting down fully (i.e. killing all processes and later
>     > starting up Linux from nothing), or suspending to ram or disk?
>     If you
>     > are suspending to ram/disk then tou may have hit the problem I
>     found,
>     > which is that once mythbackend has gone through the countdown,
>     it will
>     > never start the countdown again. I found you needed to kill
>     mythbackend
>     > as part of your suspend script (or resume script I suppose)
>     before it
>     > would work.
>     >
>     > If there's a more elegant way of prodding mythbackend so that it
>     will
>     > allow itself to start the countdown again, then I'd be pleased
>     to hear it.
>     >
>     > John
>     >
>     > --
>     > John Veness, MythTV user
>     >
>     shutting the box down,but using a acpi command. it would be an
>     interesting experiment to try putting a command to stop the backend on
>     shutdown. I'll post back results.
>     Gary
> Just checked and my shutdown script does stop the backend as well as 
> mysql before issuing the acpi shutdown command.
> Back to the drawing board again. Oddly though, it has started working 
> this morning though. I think it may have something to do with the 
> windows mythtvplayer, as I often use that to watch on the laptop, but 
> I've been watching most stuff on the myth box itself lately. I have no 
> other frontends either btw.
> gaz

There is another alternative here for getting ACPI sleep/wakeup to play 
nicely with mythtv, instead of making your suspend script kill the 
backend. I made some relatively trivial hacks to the backend source so 
it can handle a system shutdown operation which doesn't cause the 
backend process to shutdown as a side-effect. Without this, the backend 
can't keep running after a resume as you would expect, without being 
stopped and restarted. The net result of this change is that you don't 
need to stop and restart the backend. My hack (svn diff) looks like this:

Index: programs/mythbackend/scheduler.cpp
--- programs/mythbackend/scheduler.cpp  (revision 12638)
+++ programs/mythbackend/scheduler.cpp  (working copy)
@@ -1444,6 +1444,7 @@
+                                idleSince = QDateTime();

@@ -1596,6 +1597,8 @@
         // and now shutdown myself
+    m_isShuttingDown = false;

 void *Scheduler::SchedulerThread(void *param)

Basically this is a two line change which makes sure that 1) the idle 
time is correct after resume, and 2) the backend doesn't get permanently 
hung up thinking it's in the process of shutting down.

I'm using an oldish version of the 'fixes' 0.20 branch (details in the 
cut'n'paste above), but If you're happy coding in C, then this should 
point you in the right direction. In a perfect world I'd submit a patch, 
but this would require some more though as the hack above may not 
necessarily work for everyone, so it might need yet another config 
option to be added.

This has been working well for me for a long time now and helps quite a 
bit in making my combined front/back end suspend and resume quickly (< 
10sec) which is a very good thing for the WAF.

As far as I can see there should be no need to shutdown and restart mysql.


More information about the mythtv-users mailing list