Branch: Tag:

2009-10-13

2009-10-13 12:39:20 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Fixed issue where check() only loocked at a single monitor.
Improved robustness against directories without read permission.

Rev: lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:1.27

1:   //   // Basic filesystem monitor.   // - // $Id: basic.pike,v 1.26 2009/10/12 14:59:53 grubba Exp $ + // $Id: basic.pike,v 1.27 2009/10/13 12:39:20 grubba Exp $   //   // 2009-07-09 Henrik Grubbström   //
261:    // Initialize.    if (st) {    if (st->isdir) { -  array(string) files = get_dir(path); +  array(string) files = get_dir(path) || ({});    this_program::files = files;    foreach(files, string file) {    file = Stdio.append_path(path, file);
312:    (st->size != old_st->size)) {    last_change = time(1);    if (st->isdir) { -  array(string) files = get_dir(path); +  array(string) files = get_dir(path) || ({});    array(string) new_files = files;    array(string) deleted_files = ({});    if (this_program::files) {
719:    int ret = max_dir_check_interval;    int cnt;    int t = time(); -  Monitor m; +     if (sizeof(monitors)) { -  while ((m = monitor_queue->peek()) && -  m <= t) { +  Monitor m; +  while ((m = monitor_queue->peek()) && (m->next_poll <= t)) {    cnt += check_monitor(m); -  if (--scan_cnt) break; +  if (!(--scan_cnt)) { +  m = monitor_queue->peek(); +  break;    } -  +  }    if (m) {    ret = m->next_poll - t;    if (ret <= 0) ret = 1;