Skip to content

Commit

Permalink
fix(attach): make removing clients atomic (#966)
Browse files Browse the repository at this point in the history
  • Loading branch information
imsnif authored Dec 23, 2021
1 parent 3f2724d commit 0d7f22f
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ expression: last_snapshot
---
Zellij (e2e-test)  Tab #1
Pane #1 ─────────────────────────────────────────────────┐┌ Pane #2 ─────────────────────────────────────────────────┐
$ ││$ I am some text
$ ││$ I am some text
│ ││ │
│ ││ │
│ ││ │
Expand Down
102 changes: 48 additions & 54 deletions zellij-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,25 +386,23 @@ 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()
.as_ref()
.unwrap()
.senders
.send_to_screen(ScreenInstruction::RemoveClient(client_id))
.unwrap();
session_data
.write()
.unwrap()
.as_ref()
.unwrap()
.senders
.send_to_plugin(PluginInstruction::RemoveClient(client_id))
.unwrap();
}
session_data
.write()
.unwrap()
.as_ref()
.unwrap()
.senders
.send_to_screen(ScreenInstruction::RemoveClient(client_id))
.unwrap();
session_data
.write()
.unwrap()
.as_ref()
.unwrap()
.senders
.send_to_plugin(PluginInstruction::RemoveClient(client_id))
.unwrap();
if session_state.read().unwrap().clients.is_empty() {
*session_data.write().unwrap() = None;
break;
Expand All @@ -421,25 +419,23 @@ 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()
.as_ref()
.unwrap()
.senders
.send_to_screen(ScreenInstruction::RemoveClient(client_id))
.unwrap();
session_data
.write()
.unwrap()
.as_ref()
.unwrap()
.senders
.send_to_plugin(PluginInstruction::RemoveClient(client_id))
.unwrap();
}
session_data
.write()
.unwrap()
.as_ref()
.unwrap()
.senders
.send_to_screen(ScreenInstruction::RemoveClient(client_id))
.unwrap();
session_data
.write()
.unwrap()
.as_ref()
.unwrap()
.senders
.send_to_plugin(PluginInstruction::RemoveClient(client_id))
.unwrap();
}
ServerInstruction::KillSession => {
let client_ids = session_state.read().unwrap().client_ids();
Expand All @@ -461,25 +457,23 @@ 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()
.as_ref()
.unwrap()
.senders
.send_to_screen(ScreenInstruction::RemoveClient(client_id))
.unwrap();
session_data
.write()
.unwrap()
.as_ref()
.unwrap()
.senders
.send_to_plugin(PluginInstruction::RemoveClient(client_id))
.unwrap();
}
session_data
.write()
.unwrap()
.as_ref()
.unwrap()
.senders
.send_to_screen(ScreenInstruction::RemoveClient(client_id))
.unwrap();
session_data
.write()
.unwrap()
.as_ref()
.unwrap()
.senders
.send_to_plugin(PluginInstruction::RemoveClient(client_id))
.unwrap();
}
ServerInstruction::Render(mut output) => {
let client_ids = session_state.read().unwrap().client_ids();
Expand Down

0 comments on commit 0d7f22f

Please sign in to comment.