VDR 1.7.42: fix pending timers

Message ID 51515B19.6000203@tvdr.de
State New
Headers

Commit Message

Klaus Schmidinger March 26, 2013, 8:23 a.m. UTC
  There has been a bug report regarding overlapping "pending" timers.
The original posting can be found here:

   http://www.vdr-portal.de/board17-developer/board97-vdr-core/p1134445-probleme-mit-aufnahmepriorit%C3%A4ten-und-wahrscheinlich-devicebonding/#post1134445

The diagram "version 2" shows 3 timers with different priorities,
where timers 1 and 3 can record simultaneously, while timer 2 can
only record by itself. This is due to limitations imposed by
"device bonding", but similar situations may also occur in other
environments.

The problem here is that at time 'C', timer 3 starts and forces timer
2 to stop due to its higher priority. Now timer 1 would also be able to
record, but it doesn't do so until timer 2 expires. This is caused by
timers 1 and 2 being in the "pending" state, but timer 2 always being
chosen in cTimers::GetMatch(time_t t) due to its higher priority.

The attached patch fixes this.
Please apply and test it. I'm considering to include this in the
final version 2.0.0 which shall be released on sunday, so I need
to know whether it causes any negative side effects.

Klaus
  

Patch

--- timers.c	2013/03/16 10:37:10	2.17
+++ timers.c	2013/03/25 10:44:46
@@ -720,8 +720,10 @@ 
   for (cTimer *ti = First(); ti; ti = Next(ti)) {
       if (!ti->Recording() && ti->Matches(t)) {
          if (ti->Pending()) {
-            if (ti->Index() > LastPending)
+            if (ti->Index() > LastPending) {
                LastPending = ti->Index();
+               return ti;
+               }
             else
                continue;
             }