Changeset 1dbb45b9deca8465c32394889ee40088e6297634

Show
Ignore:
Timestamp:
04/22/12 17:45:45 (3 years 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
  • src/noit_check.c

    r397f56d r1dbb45b  
    222222    lc->tv_sec = (lc->tv_sec / 60) * 60 + balance_ms / 1000; 
    223223    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    } 
    226229    else { 
    227230      struct timeval test; 
  • src/noit_check_tools.c

    r41959b7 r1dbb45b  
    9797  eventer_t newe; 
    9898  struct timeval period, earliest, diff; 
    99   u_int64_t diffms, periodms, offsetms; 
     99  int64_t diffms, periodms, offsetms; 
    100100  recur_closure_t *rcl; 
    101101  int initial = last_check ? 1 : 0; 
     
    142142 
    143143  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  } 
    147153  /* determine the offset from initial schedule time that would place 
    148154   * us at the next period-aligned point past "now" */ 
     
    150156  diff.tv_sec = offsetms / 1000; 
    151157  diff.tv_usec = (offsetms % 1000) * 1000; 
    152   
     158 
    153159  memcpy(&newe->whence, last_check, sizeof(*last_check)); 
    154160  add_timeval(newe->whence, diff, &newe->whence);