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

version» Context lines:

pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:221:    mixed key = monitor_mutex->lock();    monitor_queue->remove(this);    }    }       int `<(mixed m) { return next_poll < m; }    int `>(mixed m) { return next_poll > m; }       void create()    { +  MON_WERR("Creating monitor for %O.\n", path);    Element::create(this);    register_path(1);    }       //! Call a notification callback.    //!    //! @param cb    //! Callback to call or @[UNDEFINED] for no operation.    //!    //! @param path
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:258:    //! This function is called when a change has been detected for an    //! attribute for a monitored file or directory.    //!    //! Called by @[check()] and @[check_monitor()].    //!    //! @note    //! If there is a @[data_changed()] callback, it may supersede this    //! callback if the file content also has changed.    protected void attr_changed(string path, Stdio.Stat st)    { +  MON_WERR("attr_changed(%O, %O)\n", path, st);    if (global::data_changed) {    call_callback(global::data_changed, path);    } else {    call_callback(global::attr_changed, path, st);    }    }       //! File existance callback.    //!    //! @param st
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:284:    //!    //! @note    //! For directories, @[file_created()] will be called for the subpaths    //! before the call for the directory itself. This can be used to detect    //! when the initialization for a directory is finished.    //!    //! Called by @[check()] and @[check_monitor()] the first time a monitored    //! path is checked (and only if it exists).    protected void file_exists(string path, Stdio.Stat st)    { +  MON_WERR("file_exists(%O, %O)\n", path, st);    register_path();    int t = time(1);    call_callback(global::file_exists, path, st);    if (st->mtime + (stable_time || global::stable_time) >= t) {    // Not stable yet! We guess that the mtime is a    // fair indication of when the file last changed.    last_change = st->mtime;    }    }   
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:307:    //! Status information for @[path] as obtained by    //! @expr{file_stat(path, 1)@}.    //!    //! This function is called when either a monitored path has started    //! existing, or when a new file or directory has been added to a    //! monitored directory.    //!    //! Called by @[check()] and @[check_monitor()].    protected void file_created(string path, Stdio.Stat st)    { +  MON_WERR("file_created(%O, %O)\n", path, st);    register_path();    call_callback(global::file_created, path, st);    }       //! File deletion callback.    //!    //! @param path    //! Path of the new file or directory that has been deleted.    //!    //! @param old_st    //! Stat for the file prior to deletion (if known). Note that    //! this argument is not passed along to top level function.    //!    //! This function is called when either a monitored path has stopped    //! to exist, or when a file or directory has been deleted from a    //! monitored directory.    //!    //! Called by @[check()] and @[check_monitor()].    protected void file_deleted(string path, Stdio.Stat|void old_st)    { -  +  MON_WERR("file_deleted(%O, %O)\n", path, st);    unregister_path();    call_callback(global::file_deleted, path);    }       //! Stable change callback.    //!    //! @param st    //! Status information for @[path] as obtained by    //! @expr{file_stat(path, 1)@}.    //!    //! This function is called when previous changes to @[path] are    //! considered "stable".    //!    //! "Stable" in this case means that there have been no detected    //! changes for at lease @[stable_time] seconds.    //!    //! Called by @[check()] and @[check_monitor()].    protected void stable_data_change(string path, Stdio.Stat st)    { -  +  MON_WERR("stable_data_change(%O, %O)\n", path, st);    call_callback(global::stable_data_change, path, st);    }       protected string _sprintf(int c)    {    return sprintf("Monitor(%O, %O, next: %s, st: %O)",    path, flags, ctime(next_poll) - "\n", st);    }       //! Bump the monitor to an earlier scan time.
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:451:    int file_interval_factor, int stable_time)    {    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)    { +  MON_WERR("status_change(%O, %O, 0x%04x, 0x%04x)\n", +  old_st, st, orig_flags, flags);    if (st->isdir) {    int res = 0;    array(string) files = get_dir(path) || ({});    array(string) new_files = files;    array(string) deleted_files = ({});    if (this::files) {    new_files -= this::files;    deleted_files = this::files - files;    } -  +  MON_WERR("%d files created, %d files deleted.\n", +  sizeof(new_files) sizeof(deleted_files));    this::files = files;    foreach(new_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 created file.    // Let it handle the notification.
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:696:    } else {    return 0;    }       // Note: ctime seems to change unexpectedly when running ImageMagick    // on NFS disk so we disable it for the moment [bug 5587].    if (last_change != -0x7fffffff &&    ((st->mtime != old_st->mtime) ||    /* (st->ctime != old_st->ctime) || */    (st->size != old_st->size))) { +  MON_WERR("Inode changed. New st: %O.\n", st);    last_change = time(1);    update(st);    if (status_change(old_st, st, orig_flags, flags)) return 1;    } else if (last_change < time(1) - (stable_time || global::stable_time)) { -  +  MON_WERR("Inode stable now.\n");    last_change = 0x7fffffff;    stable_data_change(path, st);    return 1;    } else if (last_change != 0x7fffffff &&    st->isdir && status_change(old_st, st, orig_flags, flags)) { -  +  MON_WERR("Directory not stable yet.\n");    // Directory not stable yet.    last_change = time(1);    update(st);    return 1; -  +  } else if (last_change != 0x7fffffff) { +  MON_WERR("Not stable yet. Age: %d seconds. Path: %O\n", +  time(1) - last_change, path); +  } else { +  MON_WERR("Inode stable still.\n");    }    return 0;    }       protected void destroy()    {    unregister_path(1);    }   }