1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-23 05:12:40 +03:00

avoid marking a tab as dead when we might reconnect it

This commit is contained in:
Wez Furlong 2019-06-28 09:01:34 -07:00
parent 4fc6914602
commit d67d4aab57
3 changed files with 17 additions and 4 deletions

View File

@ -6,4 +6,5 @@ edition = "2018"
[dependencies]
failure = "0.1"
failure_derive = "0.1"
rayon = "1.0"

View File

@ -1,9 +1,14 @@
use failure::{Error, Fallible};
use failure_derive::*;
use std::sync::{Arc, Condvar, Mutex};
type NextFunc<T> = Box<dyn FnOnce(Fallible<T>) + Send>;
pub type SpawnFunc = Box<dyn FnOnce() + Send>;
#[derive(Debug, Fail)]
#[fail(display = "Promise was dropped before completion")]
pub struct BrokenPromise {}
pub trait Executor: Send {
fn execute(&self, f: SpawnFunc);
fn clone_executor(&self) -> Box<dyn Executor>;
@ -76,7 +81,7 @@ impl<T> Default for Promise<T> {
impl<T> Drop for Promise<T> {
fn drop(&mut self) {
if let PromiseState::Waiting(core) = &mut self.state {
let err = Err(failure::err_msg("Promise was dropped before completion"));
let err = Err(BrokenPromise {}.into());
let mut locked = core.data.lock().unwrap();
if let Some(func) = locked.propagate.take() {
func(err);

View File

@ -10,7 +10,7 @@ use failure::{bail, Fallible};
use filedescriptor::Pipe;
use log::error;
use portable_pty::PtySize;
use promise::Future;
use promise::{BrokenPromise, Future};
use std::borrow::Cow;
use std::cell::RefCell;
use std::cell::RefMut;
@ -412,8 +412,15 @@ impl Renderable for RenderableState {
fn has_dirty_lines(&self) -> bool {
let mut inner = self.inner.borrow_mut();
if inner.poll().is_err() {
inner.dead = true;
if let Err(err) = inner.poll() {
// We allow for BrokenPromise here for now; for a TLS backed
// session it indicates that we'll retry. For a local unix
// domain session it is terminal... but we will detect that
// terminal condition elsewhere
if let Err(err) = err.downcast::<BrokenPromise>() {
log::error!("remote tab poll failed: {}, marking as dead", err);
inner.dead = true;
}
}
if inner.something_changed.load(Ordering::SeqCst) {
return true;