Branch: Tag:

2016-03-07

2016-03-07 18:18:53 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Filesystem.Monitor: Fix stable_data_change() for accellerated monitors.

The stable_data_change() notification was lost with the accellerated
monitors if it was on a preexisting file that was younger than the
stable time.

This adds a paranoia call_out loop to avoid losing track of the event.

785: Inside #if HAVE_EVENTSTREAM
      int(0..1) accellerated;    -  protected void file_exists(string path, Stdio.Stat st) +  protected void do_stable_check()    { -  ::file_exists(path, st); -  if ((last_change != 0x7fffffff) && accellerated) { +  check(); +  if (last_change != 0x7fffffff) {    // Not stable yet.    int t = time(1) - last_change;    if (t < 0) t = 0; -  (backend || Pike.DefaultBackend)-> -  call_out(check, (stable_time || global::stable_time) + 1 - t); +  t = (stable_time || global::stable_time) + 1 - t; +  if (t <= 0) t = 1; +  (backend || Pike.DefaultBackend)->call_out(do_stable_check, t);    }    }    -  protected void file_created(string path, Stdio.Stat st) +  protected void file_exists(string path, Stdio.Stat st)    { -  if (accellerated) { -  (backend || Pike.DefaultBackend)-> -  call_out(check, (stable_time || global::stable_time) + 1); +  ::file_exists(path, st); +  (backend || Pike.DefaultBackend)->call_out(do_stable_check, 0);    } -  +  +  protected void file_created(string path, Stdio.Stat st) +  { +  (backend || Pike.DefaultBackend)->call_out(do_stable_check, 0);    ::file_created(path, st);    }       protected void attr_changed(string path, Stdio.Stat st)    { -  if (accellerated) { -  (backend || Pike.DefaultBackend)-> -  call_out(check, (stable_time || global::stable_time) + 1); -  } +  (backend || Pike.DefaultBackend)->call_out(do_stable_check, 0);    ::attr_changed(path, st);    }   
947:    int `accellerated() { return wd != -1; }    protected int(0..) out_of_inotify_space;    -  protected void file_exists(string path, Stdio.Stat st) +  protected void do_stable_check()    { -  ::file_exists(path, st); -  if ((last_change != 0x7fffffff) && (wd != -1)) { +  check(); +  if (last_change != 0x7fffffff) {    // Not stable yet.    int t = time(1) - last_change;    if (t < 0) t = 0; -  (backend || Pike.DefaultBackend)-> -  call_out(check, (stable_time || global::stable_time) + 1 - t); +  t = (stable_time || global::stable_time) + 1 - t; +  if (t <= 0) t = 1; +  (backend || Pike.DefaultBackend)->call_out(do_stable_check, t);    }    }    -  protected void file_created(string path, Stdio.Stat st) +  protected void file_exists(string path, Stdio.Stat st)    { -  if (wd != -1) { -  (backend || Pike.DefaultBackend)-> -  call_out(check, (stable_time || global::stable_time) + 1); +  ::file_exists(path, st); +  (backend || Pike.DefaultBackend)->call_out(do_stable_check, 0);    } -  +  +  protected void file_created(string path, Stdio.Stat st) +  { +  (backend || Pike.DefaultBackend)->call_out(do_stable_check, 0);    ::file_created(path, st);    }       protected void attr_changed(string path, Stdio.Stat st)    { -  if (wd != -1) { -  (backend || Pike.DefaultBackend)-> -  call_out(check, (stable_time || global::stable_time) + 1); -  } +  (backend || Pike.DefaultBackend)->call_out(do_stable_check, 0);    ::attr_changed(path, st);    }