remove IsTabDead rpc; can infer it from poll
This commit is contained in:
1 parent
cc29782a72
commit
a2b52eb777
4 files changed
+8
-46
No files matched your search
@@ -76,5 +76,4 @@ impl Client {
|
||||
rpc!(key_down, SendKeyDown, UnitResponse);
|
||||
rpc!(mouse_event, SendMouseEvent, SendMouseEventResponse);
|
||||
rpc!(resize, Resize, UnitResponse);
|
||||
rpc!(check_tab_dead, IsTabDead, IsTabDeadResponse);
|
||||
}
|
||||
@@ -221,8 +221,6 @@ pdu! {
|
||||
SendMouseEvent: 12,
|
||||
SendPaste: 13,
|
||||
Resize: 14,
|
||||
IsTabDead: 15,
|
||||
IsTabDeadResponse: 16,
|
||||
SendMouseEventResponse: 17,
|
||||
}
|
||||
|
||||
@@ -332,16 +330,6 @@ pub struct Resize {
|
||||
pub size: PtySize,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, PartialEq, Debug)]
|
||||
pub struct IsTabDead {
|
||||
pub tab_id: TabId,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, PartialEq, Debug)]
|
||||
pub struct IsTabDeadResponse {
|
||||
pub is_dead: bool,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
@@ -150,17 +150,6 @@ impl ClientSession {
|
||||
.wait()?;
|
||||
Pdu::GetCoarseTabRenderableDataResponse(result)
|
||||
}
|
||||
Pdu::IsTabDead(IsTabDead { tab_id }) => {
|
||||
let is_dead = Future::with_executor(self.executor.clone_executor(), move || {
|
||||
let mux = Mux::get().unwrap();
|
||||
let tab = mux
|
||||
.get_tab(tab_id)
|
||||
.ok_or_else(|| format_err!("no such tab {}", tab_id))?;
|
||||
Ok(tab.is_dead())
|
||||
})
|
||||
.wait()?;
|
||||
Pdu::IsTabDeadResponse(IsTabDeadResponse { is_dead })
|
||||
}
|
||||
|
||||
Pdu::WriteToTab(WriteToTab { tab_id, data }) => {
|
||||
Future::with_executor(self.executor.clone_executor(), move || {
|
||||
@@ -262,7 +251,6 @@ impl ClientSession {
|
||||
| Pdu::SendMouseEventResponse { .. }
|
||||
| Pdu::GetCoarseTabRenderableDataResponse { .. }
|
||||
| Pdu::SpawnResponse { .. }
|
||||
| Pdu::IsTabDeadResponse { .. }
|
||||
| Pdu::UnitResponse { .. }
|
||||
| Pdu::ErrorResponse { .. } => bail!("expected a request, got {:?}", pdu),
|
||||
})
|
||||
|
||||
+8
-21
@@ -40,6 +40,7 @@ impl ClientTab {
|
||||
coarse: RefCell::new(None),
|
||||
last_poll: RefCell::new(Instant::now()),
|
||||
dirty_all: RefCell::new(true),
|
||||
dead: RefCell::new(false),
|
||||
};
|
||||
|
||||
let reader = Pipe::new().expect("Pipe::new failed");
|
||||
@@ -133,26 +134,9 @@ impl Tab for ClientTab {
|
||||
}
|
||||
|
||||
fn is_dead(&self) -> bool {
|
||||
let mut client = self.client.client.lock().unwrap();
|
||||
let is_dead = client
|
||||
.check_tab_dead(IsTabDead {
|
||||
tab_id: self.remote_tab_id,
|
||||
})
|
||||
.map(|r| r.is_dead)
|
||||
.unwrap_or_else(|e| {
|
||||
error!(
|
||||
"is_dead: local={} remote={} err={}",
|
||||
self.local_tab_id, self.remote_tab_id, e
|
||||
);
|
||||
true
|
||||
});
|
||||
if is_dead {
|
||||
error!(
|
||||
"is_dead local={} remote={} -> {}",
|
||||
self.local_tab_id, self.remote_tab_id, is_dead
|
||||
);
|
||||
}
|
||||
is_dead
|
||||
let renderable = self.renderable.borrow();
|
||||
let dead = *renderable.dead.borrow();
|
||||
dead
|
||||
}
|
||||
|
||||
fn palette(&self) -> ColorPalette {
|
||||
@@ -170,6 +154,7 @@ struct RenderableState {
|
||||
coarse: RefCell<Option<GetCoarseTabRenderableDataResponse>>,
|
||||
last_poll: RefCell<Instant>,
|
||||
dirty_all: RefCell<bool>,
|
||||
dead: RefCell<bool>,
|
||||
}
|
||||
|
||||
const POLL_INTERVAL: Duration = Duration::from_millis(50);
|
||||
@@ -229,7 +214,9 @@ impl Renderable for RenderableState {
|
||||
}
|
||||
|
||||
fn has_dirty_lines(&self) -> bool {
|
||||
self.poll().ok();
|
||||
if let Err(_) = self.poll() {
|
||||
*self.dead.borrow_mut() = true;
|
||||
}
|
||||
|
||||
let coarse = self.coarse.borrow();
|
||||
if let Some(coarse) = coarse.as_ref() {
|
||||
|
||||
Reference in new issue
Block a user