fix(attach): make removing clients atomic (#966)

This commit is contained in:
Aram Drevekenin 2021-12-23 10:44:23 +01:00 committed by GitHub
parent 3f2724dc07
commit 0d7f22f09a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 49 additions and 55 deletions

View file

@ -5,7 +5,7 @@ expression: last_snapshot
---
Zellij (e2e-test)  Tab #1 
┌ Pane #1 ─────────────────────────────────────────────────┐┌ Pane #2 ─────────────────────────────────────────────────┐
│$ ││$ I am some text█
│$ █ ││$ I am some text
│ ││ │
│ ││ │
│ ││ │

View file

@ -386,8 +386,7 @@ pub fn start_server(mut os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
.senders
.send_to_screen(ScreenInstruction::TerminalResize(min_size))
.unwrap();
// we only do this inside this if because it means there are still connected
// clients
}
session_data
.write()
.unwrap()
@ -404,7 +403,6 @@ pub fn start_server(mut os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
.senders
.send_to_plugin(PluginInstruction::RemoveClient(client_id))
.unwrap();
}
if session_state.read().unwrap().clients.is_empty() {
*session_data.write().unwrap() = None;
break;
@ -421,8 +419,7 @@ pub fn start_server(mut os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
.senders
.send_to_screen(ScreenInstruction::TerminalResize(min_size))
.unwrap();
// we only do this inside this if because it means there are still connected
// clients
}
session_data
.write()
.unwrap()
@ -440,7 +437,6 @@ pub fn start_server(mut os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
.send_to_plugin(PluginInstruction::RemoveClient(client_id))
.unwrap();
}
}
ServerInstruction::KillSession => {
let client_ids = session_state.read().unwrap().client_ids();
for client_id in client_ids {
@ -461,8 +457,7 @@ pub fn start_server(mut os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
.senders
.send_to_screen(ScreenInstruction::TerminalResize(min_size))
.unwrap();
// we only do this inside this if because it means there are still connected
// clients
}
session_data
.write()
.unwrap()
@ -480,7 +475,6 @@ pub fn start_server(mut os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
.send_to_plugin(PluginInstruction::RemoveClient(client_id))
.unwrap();
}
}
ServerInstruction::Render(mut output) => {
let client_ids = session_state.read().unwrap().client_ids();
// Here the output is of the type Option<String> sent by screen thread.