Ticket #4971: mythtv-0.21-wanttorun-hour-bigger-than-maxhour.2.patch

File mythtv-0.21-wanttorun-hour-bigger-than-maxhour.2.patch, 1.5 KB (added by stefan.becker@…, 16 years ago)

Corrected comment

  • mythtv-0.21/programs/mythbackend/housekeeper.cpp

    diff -up mythtv-0.21/programs/mythbackend/housekeeper.cpp~ mythtv-0.21/programs/mythbackend/housekeeper.cpp
    old new bool HouseKeeper::wantToRun(const QStrin 
    8787                     ((hour <= maxhour) || (hour >= minhour))) ||
    8888                    ((hour >= minhour) && (hour <= maxhour)))
    8989                {
     90                    // OK, we now know that the job is allowed to run. But we
     91                    // want to randomize the start time.
     92                    //
     93                    // Allow the job run if
     94                    // a) the caller has asked for deterministic behaviour, or
     95                    // b) we have reached the last half hour of the window, or
     96                    // c) we win a random draw with a probability of 1/N.
     97                    //
     98                    // N gets smaller the nearer we are to the end of the
     99                    // window. The "(24 + ...) % 24" makes sure the calculation
     100                    // is correct even for the case hour > minhour > maxhour.
    90101                    int minute = now.time().minute();
    91102                    if (exact ||
    92103                        (hour == maxhour && minute > 30) ||
    93                         ((random()%(((maxhour-hour)*12+(60-minute)/5 - 6) + 1)) == 0))
     104                        ((random()%((((24+maxhour-hour)%24)*12+(60-minute)/5 - 6) + 1)) == 0))
    94105                        runOK = true;
    95106                }
    96107            }