From 134267250e1f6604ba1e7c26ffa3dd53e6abfb96 Mon Sep 17 00:00:00 2001 From: MinusGix Date: Sun, 31 Jul 2022 21:01:13 -0500 Subject: [PATCH] Use recv when receiving messages and stop checking when the channel closes --- lapce-proxy/src/plugin.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lapce-proxy/src/plugin.rs b/lapce-proxy/src/plugin.rs index 67a7deb0..b6801813 100644 --- a/lapce-proxy/src/plugin.rs +++ b/lapce-proxy/src/plugin.rs @@ -248,7 +248,7 @@ fn start_plugin( let (tx, rx) = mpsc::channel(); thread::spawn(move || loop { - match rx.try_recv() { + match rx.recv() { Ok(PluginTransmissionMessage::Initialize) => { let initialize = local_plugin .instance @@ -283,7 +283,9 @@ fn start_plugin( } break; } - _ => {} + // There was an error when receiving, which means that the other end was closed. + // So we simply shutdown this thread by breaking out of the loop + Err(_) => break, } }); tx.send(PluginTransmissionMessage::Initialize)?;