diff -up mythtv-0.21/programs/mythbackend/housekeeper.cpp~ mythtv-0.21/programs/mythbackend/housekeeper.cpp
old
|
new
|
bool HouseKeeper::wantToRun(const QStrin |
87 | 87 | ((hour <= maxhour) || (hour >= minhour))) || |
88 | 88 | ((hour >= minhour) && (hour <= maxhour))) |
89 | 89 | { |
| 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. |
90 | 101 | int minute = now.time().minute(); |
91 | 102 | if (exact || |
92 | 103 | (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)) |
94 | 105 | runOK = true; |
95 | 106 | } |
96 | 107 | } |