Branch: Tag:

2017-10-06

2017-10-06 12:50:35 by Karl Gustav Sterneberg <kg@roxen.com>

Fixed bug in Monitor->update().

When checking if class was initialized code looked at the variable
"next_pol", this behaviour caused a bug if a subclass set "next_pol" to
0. This resulted in poll every second.

225:    // to indicate immediate stabilization    // (avoid an extra check() round to    // let the stat stabilize). +  private bool initialized = false;    array(string) files;       //! Event tracing callback.
483:    // adjusted to the max interval.    int mtime = max(st->mtime, st->ctime);    int d = ((time(1) - mtime) >> 2); -  if (!next_poll && (d >= 0)) { +  if (!initialized && (d >= 0)) {    // Assume that mtime is reasonable at startup.    last_change = mtime;    }
496:    if (d < 0) d = 1;    if (d < delta) delta = d;    } -  if (!next_poll) { +  if (!initialized) {    // Attempt to distribute polls evenly at startup, and to    // make sure that the full set of directory contents is    // found reasonably fast.    delta = 1 + random(delta >> 2); -  +  initialized = true;    }       MON_WERR("Next poll in %d seconds.\n", (delta || 1));