Changeset 1dbb45b9deca8465c32394889ee40088e6297634
- Timestamp:
- 04/22/12 17:45:45
(1 year ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1335116745 -0400
- git-parent:
[5fd1894ad04542945430bed21cc582a937f8edcb]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1335116745 -0400
- Message:
If the period is less than 60000, it is possible to schedule the
"last check" (as faked at boot) to be in the future, which then
causes a negative roll in the calculation of the offset causing
the next check to be scheduled sometime after the death of our sun:
Sun Jul 24 08:13:48 584556061
We should handle this case and appropriately adjust the faked last
fire time to be in the past by iteratively subtracting period until
we get there.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r397f56d |
r1dbb45b |
|
| 222 | 222 | lc->tv_sec = (lc->tv_sec / 60) * 60 + balance_ms / 1000; |
|---|
| 223 | 223 | lc->tv_usec = (balance_ms % 1000) * 1000; |
|---|
| 224 | | if(compare_timeval(*_now, *lc) < 0) |
|---|
| 225 | | sub_timeval(*lc, period, lc); |
|---|
| | 224 | if(compare_timeval(*_now, *lc) < 0) { |
|---|
| | 225 | do { |
|---|
| | 226 | sub_timeval(*lc, period, lc); |
|---|
| | 227 | } while(compare_timeval(*_now, *lc) < 0); |
|---|
| | 228 | } |
|---|
| 226 | 229 | else { |
|---|
| 227 | 230 | struct timeval test; |
|---|
| r41959b7 |
r1dbb45b |
|
| 97 | 97 | eventer_t newe; |
|---|
| 98 | 98 | struct timeval period, earliest, diff; |
|---|
| 99 | | u_int64_t diffms, periodms, offsetms; |
|---|
| | 99 | int64_t diffms, periodms, offsetms; |
|---|
| 100 | 100 | recur_closure_t *rcl; |
|---|
| 101 | 101 | int initial = last_check ? 1 : 0; |
|---|
| … | … | |
| 142 | 142 | |
|---|
| 143 | 143 | newe = eventer_alloc(); |
|---|
| 144 | | sub_timeval(earliest, *last_check, &diff); |
|---|
| 145 | | /* calculat the differnet between the initial schedule time and "now" */ |
|---|
| 146 | | diffms = diff.tv_sec * 1000 + diff.tv_usec / 1000; |
|---|
| | 144 | /* calculate the differnet between the initial schedule time and "now" */ |
|---|
| | 145 | if(compare_timeval(earliest, *last_check) >= 0) { |
|---|
| | 146 | sub_timeval(earliest, *last_check, &diff); |
|---|
| | 147 | diffms = diff.tv_sec * 1000 + diff.tv_usec / 1000; |
|---|
| | 148 | } |
|---|
| | 149 | else { |
|---|
| | 150 | noitL(noit_error, "time is going backwards. abort.\n"); |
|---|
| | 151 | abort(); |
|---|
| | 152 | } |
|---|
| 147 | 153 | /* determine the offset from initial schedule time that would place |
|---|
| 148 | 154 | * us at the next period-aligned point past "now" */ |
|---|
| … | … | |
| 150 | 156 | diff.tv_sec = offsetms / 1000; |
|---|
| 151 | 157 | diff.tv_usec = (offsetms % 1000) * 1000; |
|---|
| 152 | | |
|---|
| | 158 | |
|---|
| 153 | 159 | memcpy(&newe->whence, last_check, sizeof(*last_check)); |
|---|
| 154 | 160 | add_timeval(newe->whence, diff, &newe->whence); |
|---|