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

version» Context lines:

pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:1:   //   // Basic filesystem monitor.   // - // $Id: basic.pike,v 1.13 2009/07/17 15:56:50 grubba Exp $ + // $Id: basic.pike,v 1.14 2009/07/17 16:00:20 grubba Exp $   //   // 2009-07-09 Henrik Grubbström   //      //! Basic filesystem monitor.   //!   //! This module is intended to be used for incremental scanning of   //! a filesystem.      //! The default maximum number of seconds between checks of directories
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:240:   //!   //! This function is called by @[check_monitor()] to schedule the   //! next check.   protected void update_monitor(Monitor m, Stdio.Stat st)   {    int delta = m->max_dir_check_interval || max_dir_check_interval;    m->st = st;    if (!st || !st->isdir) {    delta *= m->file_interval_factor || file_interval_factor;    } +  if (!next_poll) { +  // Attempt to distribute polls evenly at startup. +  delta = 1 + random(delta); +  }    if (st) {    int d = 1 + ((time(1) - st->mtime)>>4);    if (d < 0) d = m->max_dir_check_interval;    if (d < delta) delta = d;    d = 1 + ((time(1) - st->ctime)>>4);    if (d < 0) d = m->max_dir_check_interval;    if (d < delta) delta = d;    }    m->next_poll = time(1) + (delta || 1);    monitor_queue->adjust(m);