Fix Neovim connection deadlock by dropping NVIM_CONN lock across await boundary
This commit is contained in:
1 parent
b98f95d9d8
commit
9870626045
2 files changed
+9
-5
No files matched your search
@@ -126,10 +126,12 @@ pub struct NvimRequest {
|
||||
static NVIM_CONN: LazyLock<Arc<Mutex<Option<mpsc::Sender<NvimRequest>>>>> = LazyLock::new(|| Arc::new(Mutex::new(None)));
|
||||
|
||||
async fn get_nvim_connection() -> Result<mpsc::Sender<NvimRequest>, String> {
|
||||
let mut conn_lock = NVIM_CONN.lock().await;
|
||||
if let Some(sender) = conn_lock.as_ref() {
|
||||
if !sender.is_closed() {
|
||||
return Ok(sender.clone());
|
||||
{
|
||||
let conn_lock = NVIM_CONN.lock().await;
|
||||
if let Some(sender) = conn_lock.as_ref() {
|
||||
if !sender.is_closed() {
|
||||
return Ok(sender.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,6 +230,7 @@ async fn get_nvim_connection() -> Result<mpsc::Sender<NvimRequest>, String> {
|
||||
}
|
||||
});
|
||||
|
||||
let mut conn_lock = NVIM_CONN.lock().await;
|
||||
*conn_lock = Some(tx.clone());
|
||||
Ok(tx)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user