Skip to content

Commit

Permalink
correctly grabbing the ownership of index files. (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
amosbird authored and MaskRay committed Oct 24, 2019
1 parent 705dc7c commit 4ab51fe
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/pipeline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,13 @@ bool Indexer_Parse(DiagnosticsPublisher *diag_pub, WorkingFiles *working_files,
}
}

// Grab the ownership
if (reparse) {
std::lock_guard<std::mutex> 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;
Expand All @@ -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<std::mutex> lock(vfs->mutex);
VFS::State &state = vfs->state[path_to_index];
if (state.owner == g_thread_id)
state.stage = 0;
return true;
}

Expand Down

0 comments on commit 4ab51fe

Please sign in to comment.