fix: ensure pty_writer thread closes (#1422)

This commit is contained in:
Thomas Linford 2022-05-17 20:29:06 +02:00 committed by GitHub
parent 9b184a351b
commit e663ef2db7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 0 deletions

View file

@ -116,6 +116,7 @@ impl Drop for SessionMetaData {
let _ = self.senders.send_to_pty(PtyInstruction::Exit);
let _ = self.senders.send_to_screen(ScreenInstruction::Exit);
let _ = self.senders.send_to_plugin(PluginInstruction::Exit);
let _ = self.senders.send_to_pty_writer(PtyWriteInstruction::Exit);
let _ = self.screen_thread.take().unwrap().join();
let _ = self.pty_thread.take().unwrap().join();
let _ = self.wasm_thread.take().unwrap().join();

View file

@ -5,12 +5,14 @@ use crate::thread_bus::Bus;
#[derive(Debug, Clone)]
pub(crate) enum PtyWriteInstruction {
Write(Vec<u8>, i32),
Exit,
}
impl From<&PtyWriteInstruction> for PtyWriteContext {
fn from(tty_write_instruction: &PtyWriteInstruction) -> Self {
match *tty_write_instruction {
PtyWriteInstruction::Write(..) => PtyWriteContext::Write,
PtyWriteInstruction::Exit => PtyWriteContext::Exit,
}
}
}
@ -29,6 +31,9 @@ pub(crate) fn pty_writer_main(bus: Bus<PtyWriteInstruction>) {
log::error!("failed to drain terminal: {}", e);
};
}
PtyWriteInstruction::Exit => {
break;
}
}
}
}

View file

@ -343,4 +343,5 @@ pub enum ServerContext {
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
pub enum PtyWriteContext {
Write,
Exit,
}