fix(attach): make removing clients atomic
@@ -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.
