Skip to content

Commit

Permalink
Reset aux channel properly on reconnection
Browse files Browse the repository at this point in the history
  • Loading branch information
lionel- committed May 29, 2024
1 parent c0bfc03 commit 9763c7b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions crates/ark/src/lsp/main_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,17 @@ impl AuxiliaryState {
// Channels for communication with the auxiliary loop
let (auxiliary_event_tx, auxiliary_event_rx) = tokio_unbounded_channel::<AuxiliaryEvent>();

// Set global instance of this channel. This is used for logging
// messages from a free function.
// Set global instance of this channel. This is used for interacting
// with the auxiliary loop (logging messages or spawning a task) from
// free functions.
unsafe {
AUXILIARY_EVENT_TX.set(auxiliary_event_tx.clone()).unwrap();
if let Some(val) = AUXILIARY_EVENT_TX.get_mut() {
// Reset channel if already set. Happens e.g. on reconnection after a refresh.
*val = auxiliary_event_tx.clone();
} else {
// Set channel for the first time
AUXILIARY_EVENT_TX.set(auxiliary_event_tx.clone()).unwrap();
}
}

// List of pending tasks for which we manage the lifecycle (mainly relay
Expand Down

0 comments on commit 9763c7b

Please sign in to comment.