From 66b027910a1ad319cd3e8c4680f80271dbda1676 Mon Sep 17 00:00:00 2001 From: Amos Bird Date: Tue, 21 Aug 2018 00:57:50 +0800 Subject: [PATCH] correctly grabbing the ownership of index files. (#54) --- src/pipeline.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/pipeline.cc b/src/pipeline.cc index 053d4f4f..5a43a01f 100644 --- a/src/pipeline.cc +++ b/src/pipeline.cc @@ -194,6 +194,13 @@ bool Indexer_Parse(DiagnosticsPublisher *diag_pub, WorkingFiles *working_files, } } + // Grab the ownership + if (reparse) { + std::lock_guard lock(vfs->mutex); + vfs->state[path_to_index].owner = g_thread_id; + vfs->state[path_to_index].stage = 0; + } + if (reparse < 2) { LOG_S(INFO) << "load cache for " << path_to_index; auto dependencies = prev->dependencies; @@ -207,11 +214,6 @@ bool Indexer_Parse(DiagnosticsPublisher *diag_pub, WorkingFiles *working_files, IndexUpdate update = IndexUpdate::CreateDelta(nullptr, prev.get()); on_indexed->PushBack(std::move(update), request.is_interactive); } - - std::lock_guard lock(vfs->mutex); - VFS::State &state = vfs->state[path_to_index]; - if (state.owner == g_thread_id) - state.stage = 0; return true; }