From 8fb699758b65901c04293dedb6ae06b6764090b2 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sun, 26 Apr 2015 09:30:29 -0700 Subject: [PATCH] age out: properly clean up lc_files linkage too Summary: didn't catch this last night because I was focused mostly on Linux. On case insensitive filesystems we also need to clean up the lc_files linkage to avoid a crash during age out. The multiple attempts I added to the integration test trigger this issue: `arc unit tests/integration/age.php` Refs: https://github.com/facebook/watchman/issues/96 --- arcanist/lib/WatchmanInstance.php | 8 ++++++++ root.c | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/arcanist/lib/WatchmanInstance.php b/arcanist/lib/WatchmanInstance.php index aaed150392e4..0d06f2e316aa 100644 --- a/arcanist/lib/WatchmanInstance.php +++ b/arcanist/lib/WatchmanInstance.php @@ -238,6 +238,14 @@ function start() { throw new Exception("Failed to talk to watchman on $sockname"); } stream_set_timeout($this->sock, self::TIMEOUT); + + // If you're debugging and want to attach a debugger, then: + // `WATCHMAN_DEBUG_WAIT=1 arc unit tests/integration/age.php` + // then gdb -p or lldb -p with the PID it prints out + if (getenv("WATCHMAN_DEBUG_WAIT")) { + printf("PID: %d\n", $this->getProcessID()); + sleep(10); + } } private function fwrite_all($sock, $buf) { diff --git a/root.c b/root.c index 4e8068d2cd52..dce41df1f69c 100644 --- a/root.c +++ b/root.c @@ -1416,6 +1416,17 @@ static void age_out_file(w_root_t *root, w_ht_t *aged_dir_names, // Remove the entry from the containing dir hash w_ht_del(file->parent->dirs, w_ht_ptr_val(full_name)); } + if (file->parent->lc_files) { + // Remove the entry from the containing lower case files hash, + // but only it it matches us (it may point to a different file + // node with a differently-cased name) + w_string_t *lc_name = w_string_dup_lower(file->name); + if (w_ht_get(file->parent->lc_files, w_ht_ptr_val(lc_name)) + == w_ht_ptr_val(file)) { + w_ht_del(file->parent->lc_files, w_ht_ptr_val(lc_name)); + } + w_string_delref(lc_name); + } // resolve the dir of the same name and mark it for later removal // from our internal datastructures