From 2ea093170c9b637e4189cb2f95941eff717e8867 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Mon, 15 Mar 2021 06:37:46 -0700 Subject: [PATCH] mux: avoid panic if prune_dead_windows is called indirectly refs: #542 --- mux/src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mux/src/lib.rs b/mux/src/lib.rs index 46e915a95..13555459a 100644 --- a/mux/src/lib.rs +++ b/mux/src/lib.rs @@ -361,7 +361,13 @@ impl Mux { let dead_tab_ids: Vec; { - let mut windows = self.windows.borrow_mut(); + let mut windows = match self.windows.try_borrow_mut() { + Ok(w) => w, + Err(_) => { + // It's ok if our caller already locked it; we can prune later. + return; + } + }; for (window_id, win) in windows.iter_mut() { win.prune_dead_tabs(&live_tab_ids); if win.is_empty() {