[unison-svn] r517 - in trunk/src: . fsmonitor/linux fsmonitor/windows

[email protected]
Newsgroups gmane.network.unison.devel
Message-ID <[email protected]>
Author: vouillon
Date: 2012-11-20 06:01:22 -0500 (Tue, 20 Nov 2012)
New Revision: 517

Modified:
   trunk/src/RECENTNEWS
   trunk/src/fsmonitor/linux/watcher.ml
   trunk/src/fsmonitor/windows/watcher.ml
   trunk/src/mkProjectInfo.ml
Log:
* File system monitoring: the file watcher now fails when unable to
  watch a directory, rather than silently ignoring the issue


Modified: trunk/src/RECENTNEWS
===================================================================
--- trunk/src/RECENTNEWS	2012-09-24 11:44:38 UTC (rev 516)
+++ trunk/src/RECENTNEWS	2012-11-20 11:01:22 UTC (rev 517)
@@ -1,3 +1,9 @@
+CHANGES FROM VERSION 2.46.12
+
+* File system monitoring: the file watcher now fails when unable to
+  watch a directory, rather than silently ignoring the issue
+
+-------------------------------
 CHANGES FROM VERSION 2.46.10
 
 * File system monitoring: more robust communication with the helper program

Modified: trunk/src/fsmonitor/linux/watcher.ml
===================================================================
--- trunk/src/fsmonitor/linux/watcher.ml	2012-09-24 11:44:38 UTC (rev 516)
+++ trunk/src/fsmonitor/linux/watcher.ml	2012-11-20 11:01:22 UTC (rev 517)
@@ -196,6 +196,8 @@
           Watchercommon.error
             ("error while handling events: " ^ Watchercommon.format_exc e)))
 
+let i = ref 0
+
 let release_watch file =
   match get_watch file with
     None ->
@@ -204,6 +206,7 @@
       set_watch file None;
       let s = IntSet.remove (get_id file) (Hashtbl.find watcher_by_id id) in
       if IntSet.is_empty s then begin
+        incr i; if !i mod 32 = 0 then Lwt_unix.run (Lwt_unix.yield ());
         begin try
           Lwt_inotify.rm_watch st id
           (* Will fail with EINVAL if the file has been deleted... *)
@@ -234,7 +237,14 @@
   with Inotify.Error (_, no) ->
     release_watch file;
     match no with
-      2 | 13 | 20 | 28 | 40 ->
+      2 (* ENOENT *) ->
+        Watchercommon.error
+          (Format.sprintf "file '%s' does not exist" path)
+    | 28 (* ENOSPC *) ->
+        Watchercommon.error "cannot add a watcher: system limit reached"
+    | 13 (* EACCES *) | 20 (* ENOTDIR *) | 40 (* ELOOP *) ->
+        (* These errors should be well handled by Unison (they will
+           result in errors during update detection *)
         ()
     | _ ->
         Watchercommon.error

Modified: trunk/src/fsmonitor/windows/watcher.ml
===================================================================
--- trunk/src/fsmonitor/windows/watcher.ml	2012-09-24 11:44:38 UTC (rev 516)
+++ trunk/src/fsmonitor/windows/watcher.ml	2012-11-20 11:01:22 UTC (rev 517)
@@ -188,10 +188,10 @@
       try
         watch_info.handle <- Some (watch_root_directory path file)
       with Unix.Unix_error _ as e ->
-        if !Watchercommon.debug then
-          Format.eprintf
-            "Error while starting to watch for changes: %s@."
-            (Watchercommon.format_exc e)
+        Watchercommon.error
+          (Format.sprintf
+             "Error while starting to watch for changes: %s@."
+             (Watchercommon.format_exc e))
     end;
     let mapping =
       try Shortnames.in_directory path with Unix.Unix_error _ -> [] in

Modified: trunk/src/mkProjectInfo.ml
===================================================================
--- trunk/src/mkProjectInfo.ml	2012-09-24 11:44:38 UTC (rev 516)
+++ trunk/src/mkProjectInfo.ml	2012-11-20 11:01:22 UTC (rev 517)
@@ -88,3 +88,4 @@
 
 
 
+
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.