Skip to content

Commit c6dbf40

Browse files
bors[bot]matklad
andauthored
Merge #2901
2901: Cancel requests during shutdown r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
2 parents 8a4c248 + b90ea64 commit c6dbf40

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

crates/ra_ide/src/change.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,15 @@ impl LibraryData {
166166
const GC_COOLDOWN: time::Duration = time::Duration::from_millis(100);
167167

168168
impl RootDatabase {
169+
pub(crate) fn request_cancellation(&mut self) {
170+
let _p = profile("RootDatabase::request_cancellation");
171+
self.salsa_runtime_mut().synthetic_write(Durability::LOW);
172+
}
173+
169174
pub(crate) fn apply_change(&mut self, change: AnalysisChange) {
170175
let _p = profile("RootDatabase::apply_change");
176+
self.request_cancellation();
171177
log::info!("apply_change {:?}", change);
172-
{
173-
let _p = profile("RootDatabase::apply_change/cancellation");
174-
self.salsa_runtime_mut().synthetic_write(Durability::LOW);
175-
}
176178
if !change.new_roots.is_empty() {
177179
let mut local_roots = Vec::clone(&self.local_roots());
178180
for (root_id, is_local) in change.new_roots {

crates/ra_ide/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ impl AnalysisHost {
202202
pub fn per_query_memory_usage(&mut self) -> Vec<(String, ra_prof::Bytes)> {
203203
self.db.per_query_memory_usage()
204204
}
205+
pub fn request_cancellation(&mut self) {
206+
self.db.request_cancellation();
207+
}
205208
pub fn raw_database(
206209
&self,
207210
) -> &(impl hir::db::HirDatabase + salsa::Database + ra_db::SourceDatabaseExt) {

crates/ra_lsp_server/src/main_loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ pub fn main_loop(
210210
)?;
211211
}
212212
}
213-
213+
world_state.analysis_host.request_cancellation();
214214
log::info!("waiting for tasks to finish...");
215215
task_receiver.into_iter().for_each(|task| {
216216
on_task(task, &connection.sender, &mut loop_state.pending_requests, &mut world_state)

0 commit comments

Comments
 (0)