Branch: Tag:

2016-02-08

2016-02-08 13:15:12 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Filesystem.Monitor [Inotify]: Reduce the number of complaints.

The inotify kernel subsystem has a maximum number of concurrent
watchpoints (controlled via /proc/sys/fs/inotify/max_user_watches).
With the default at just 8192 it is not hard to run out of watchpoints,
at which point the subsystem will start to complain.

With this change only every ~100th failure of this type will be logged
to stderr.

943:       protected int wd = -1;    int `accellerated() { return wd != -1; } +  protected int(0..) out_of_inotify_space;       protected void file_exists(string path, Stdio.Stat st)    {
1016: Inside #if undefined(INHIBIT_INOTIFY_MONITOR)
      if (new_wd != -1) {    MON_WERR("Registered %O with %O ==> %d.\n", path, instance, new_wd); +  out_of_inotify_space = 0;    // We shouldn't need to be polled.    if (!initial) {    MON_WERR("Unregistering from polling.\n");
1030: Inside #if undefined(INHIBIT_INOTIFY_MONITOR)
   }    }    }) { +  if (!has_value(lower_case(describe_error(err)), "no space left")) {    master()->handle_error (err); -  +  } else if (!(out_of_inotify_space++ % 100)) { +  werror("Out of inotify space (%d attempts):\n", out_of_inotify_space); +  master()->handle_error (err); +  werror("Consider increasing '/proc/sys/fs/inotify/max_user_watches'.\n");    }    } -  +  }       if (st && !err)    return; // Return early if setup was successful, i.e. avoid