pike.git / lib / modules / Filesystem.pmod / Monitor.pmod / basic.pike

version» Context lines:

pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:408:    //! @param st    //! New stat for the monitor.    //!    //! This function is called by @[check()] to schedule the    //! next check.    protected void update(Stdio.Stat st)    {    int delta = max_dir_check_interval || global::max_dir_check_interval;    this::st = st;    +  if (!st || !st->isdir) { +  delta *= file_interval_factor || global::file_interval_factor; +  } +     if (st) {    // Start with a delta proportional to the time since mtime/ctime,    // but bound this to the max setting. A stat in the future will be    // adjusted to the max interval. -  int d = -  (stable_time || global::stable_time) + -  ((time(1) - max(st->mtime, st->ctime)) >> 2); -  if (d < 0) d = max_dir_check_interval || global::max_dir_check_interval; -  if (d < delta) delta = d; +  int mtime = max(st->mtime, st->ctime); +  int d = ((time(1) - mtime) >> 2); +  if (!next_poll && (d >= 0)) { +  // Assume that mtime is reasonable at startup. +  last_change = mtime;    } -  +  if ((d >= 0) && (d < delta)) delta = d; +  }    if (last_change <= time(1)) {    // Time until stable.    int d = last_change + (stable_time || global::stable_time) - time(1);    d >>= 1;    if (d < 0) d = 1;    if (d < delta) delta = d; -  } else if (!st || !st->isdir) { -  delta *= file_interval_factor || global::file_interval_factor; +     } -  +     if (!next_poll) {    // Attempt to distribute polls evenly at startup.    delta = 1 + random(delta);    }    -  +  MON_WERR("Next poll in %d seconds.\n", (delta || 1));    next_poll = time(1) + (delta || 1);    adjust_monitor(this);    }       //! Check if this monitor should be removed automatically.    void check_for_release(int mask, int flags)    {    if ((this::flags & mask) == flags) {    m_delete(monitors, path);    release_monitor(this);