From 6ea72eed5b5fd60e751db694be5956ca1b7e84d1 Mon Sep 17 00:00:00 2001 From: Martin Karlgren <marty@roxen.com> Date: Wed, 21 Oct 2015 10:33:35 +0200 Subject: [PATCH] Filesystem.Monitor: Let inotify monitors fallback to poll if file doesn't exist. --- lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike b/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike index f129fac199..ac6c6a8b61 100644 --- a/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike +++ b/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike @@ -979,6 +979,7 @@ protected class InotifyMonitor } Stdio.Stat st = file_stat (path, 1); + mixed err; if (st && st->isdir) { // Note: We only want to add watchers on directories. File // notifications will take place on the directory watch @@ -986,7 +987,7 @@ protected class InotifyMonitor // on individual files is handled in the inotify_event // callback. - if (mixed err = catch { + if (err = catch { int new_wd = instance->add_watch(path, System.Inotify.IN_MOVED_FROM | System.Inotify.IN_UNMOUNT | @@ -1021,7 +1022,9 @@ protected class InotifyMonitor } } - return; + if (st && !err) + return; // Return early if setup was successful, i.e. avoid + // registering a polling monitor. #endif /* !INHIBIT_INOTIFY_MONITOR */ MON_WERR("Registering %O for polling.\n", path); -- GitLab