Fix task memory leak in nvim-core pending request cleanup loop
This commit is contained in:
1 parent
ed42f738f1
commit
84672a00b9
1 file changed
+3
@@ -237,6 +237,9 @@ async fn get_nvim_connection() -> Result<mpsc::Sender<NvimRequest>, String> {
|
|||||||
let mut interval = tokio::time::interval(tokio::time::Duration::from_secs(10));
|
let mut interval = tokio::time::interval(tokio::time::Duration::from_secs(10));
|
||||||
loop {
|
loop {
|
||||||
interval.tick().await;
|
interval.tick().await;
|
||||||
|
if Arc::strong_count(&pending_clone3) <= 1 {
|
||||||
|
break; // Socket closed and other tasks finished, no need to keep cleaning up
|
||||||
|
}
|
||||||
pending_clone3.lock().await.retain(|_, sender| !sender.is_closed());
|
pending_clone3.lock().await.retain(|_, sender| !sender.is_closed());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user