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

version» Context lines:

pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:475:    {    global::monitor(path, flags, max_dir_check_interval,    file_interval_factor, stable_time);    }       //! Called when the status has changed for an existing file.    protected int(0..1) status_change(Stdio.Stat old_st, Stdio.Stat st,    int orig_flags, int flags)    {    if (st->isdir) { +  int res = 0;    array(string) files = get_dir(path) || ({});    array(string) new_files = files;    array(string) deleted_files = ({});    if (this_program::files) {    new_files -= this_program::files;    deleted_files = this_program::files - files;    }    this_program::files = files;    foreach(new_files, string file) { -  if(filter_file(file)) continue; +  res = 1;    file = canonic_path(Stdio.append_path(path, file)); -  +  if(filter_file(file)) continue;    Monitor m2 = monitors[file];    mixed err = catch {    if (m2) {    // We have a separate monitor on the created file.    // Let it handle the notification.    m2->check(flags);    }    };    if (this_program::flags & MF_RECURSE) {    monitor(file, orig_flags | MF_AUTO | MF_HARD,    max_dir_check_interval,    file_interval_factor,    stable_time);    monitors[file]->check();    } else if (!m2) {    file_created(file, file_stat(file, 1));    }    }    foreach(deleted_files, string file) { -  +  res = 1;    file = canonic_path(Stdio.append_path(path, file)); -  +  if(filter_file(file)) continue;    Monitor m2 = monitors[file];    mixed err = catch {    if (m2) {    // We have a separate monitor on the deleted file.    // Let it handle the notification.    m2->check(flags);    }    };    if (this_program::flags & MF_RECURSE) {    // The monitor for the file has probably removed itself,
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:527:    // don't need to do anything more here.    } else if (!m2) {    file_deleted(file);    }    if (err) throw(err);    }    if (flags & MF_RECURSE) {    // Check the remaining files in the directory soon.    foreach(((files - new_files) - deleted_files), string file) {    file = canonic_path(Stdio.append_path(path, file)); +  if(filter_file(file)) continue;    Monitor m2 = monitors[file];    if (m2) {    m2->bump(flags); -  +  } else { +  // Lost update due to race-condition: +  // +  // Exist ==> Deleted ==> Exists +  // +  // with no update of directory inbetween. +  // +  // Create the lost submonitor again. +  res = 1; +  monitor(file, orig_flags | MF_AUTO | MF_HARD, +  max_dir_check_interval, +  file_interval_factor, +  stable_time); +  monitors[file]->check();    }    }    } -  if (sizeof(new_files) || sizeof(deleted_files)) return 1; +  return res;    } else {    attr_changed(path, st);    return 1;    }    return 0;    }       //! Check for changes.    //!    //! @param flags