From 9539b430f7974bf0bbeca585fbe23afd6ef95162 Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Thu, 31 Mar 2016 14:42:32 -0700 Subject: [PATCH] Create symlinks in near future when merging Summary:public It could happen that the modification times of symbolic links and original files checked by reactive mode could be exactly the same. In this case, some files would perpetually be re-analyzed. This diff creates symlinks and sets their accessed and modified times to 1 second in the future so that strict timestamp checking is robust. Reviewed By: cristianoc Differential Revision: D3098451 fb-gh-sync-id: 3724468 fbshipit-source-id: 3724468 --- infer/src/backend/DB.ml | 2 +- infer/src/backend/mergeCapture.ml | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/infer/src/backend/DB.ml b/infer/src/backend/DB.ml index 692ce951b..2aa1842d1 100644 --- a/infer/src/backend/DB.ml +++ b/infer/src/backend/DB.ml @@ -337,7 +337,7 @@ let infer_start_time = lazy let file_was_updated_after_start fname = if file_exists fname then let file_mtime = file_modified_time fname in - file_mtime >= Lazy.force infer_start_time + file_mtime > Lazy.force infer_start_time else (* since file doesn't exist, it wasn't modified *) false diff --git a/infer/src/backend/mergeCapture.ml b/infer/src/backend/mergeCapture.ml index 909520c89..c8a987c99 100644 --- a/infer/src/backend/mergeCapture.ml +++ b/infer/src/backend/mergeCapture.ml @@ -63,6 +63,12 @@ let rec slink ~stats src dst = begin if Sys.file_exists dst then Sys.remove dst; Unix.symlink src dst; + (* Set the accessed and modified time of the new symlink to be slightly in the future. Due to + the coarse precision of the timestamps, it is possible for the source and destination of a + link to have the same modification time. When this happens, the files will be considered to + need re-analysis every time, indefinitely. *) + let near_future = Unix.gettimeofday () +. 1. in + Unix.utimes dst near_future near_future ; stats.files_linked <- stats.files_linked + 1; end