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

version» Context lines:

pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:913:      //! Event callback for Inotify.   protected void inotify_event(int wd, int event, int cookie, string(8bit) path)   {    MON_WERR("inotify_event(%O, %s, %O, %O)...\n",    wd, System.Inotify.describe_mask(event), cookie, path);    string(8bit) icookie = inotify_cookie(wd);    Monitor m;    if((m = monitors[icookie])) {    if (sizeof (path)) { -  string full_path = canonic_path (combine_path (m->path, path)); +  string full_path = canonic_path(Stdio.append_path(m->path, path));    // We're interested in the sub monitor, if it exists. -  if (Monitor submon = monitors[full_path]) +  if (Monitor submon = monitors[full_path]) {    m = submon; -  +  } else if (m->flags & MF_RECURSE) { +  // We've missed creation of the submonitor. +  // +  // This can happen in the +  // +  // Exist ==> Deleted ==> Exists +  // +  // with no update of the directory inbetween race-condition. +  // +  // Create the submonitor. +  MON_WERR("Monitor lost for path %O.\n", full_path); +  monitor(full_path, m->flags | MF_AUTO | MF_HARD, +  m->max_dir_check_interval, +  m->file_interval_factor, +  m->stable_time); +  m = monitors[full_path]; +  m->check(0); // Init monitor.    }    } -  +  }       if (m) {    if (event == System.Inotify.IN_IGNORED) {    // This Inotify watch has been removed    // (either by us or automatically).    MON_WERR("### Monitor watch descriptor %d is no more.\n", wd);    m_delete(monitors, icookie);    }    mixed err = catch {    if (event & System.Inotify.IN_CLOSE_WRITE)    // File marked as stable immediately.    m->last_change = -0x7fffffff;    m->check(0);    };    if (err) {    master()->handle_error(err);    }    } else { -  MON_WERR("No monitor found for path %O.\n", path); +  // Most likely not reached. +  MON_WERR("Monitor not found for cookie %O, path %O.\n", icookie, path);    }   }      protected void start_accelerator()   {    MON_WERR("Creating Inotify monitor instance.\n");    instance = System.Inotify._Instance();    if (backend) instance->set_backend(backend);    instance->set_event_callback(inotify_event);    if (co_id) {