Skip to content

Commit

Permalink
improve: change loop to thread join
Browse files Browse the repository at this point in the history
  • Loading branch information
luftaquila committed May 16, 2024
1 parent 8b2a427 commit a61c0e3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 0 additions & 2 deletions src/bin/transistor-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,5 @@ fn main() -> Result<(), Error> {

server.start(client_config);

loop {}

Ok(())
}
6 changes: 5 additions & 1 deletion src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl Server {
let disp_ids = self.disp_ids.clone();

/* spawn tcp handler thread */
thread::spawn(move || {
let thread = thread::spawn(move || {
handle_client(current, clients, displays, disp_ids, authorized, tx1, rx1);
});

Expand Down Expand Up @@ -204,6 +204,10 @@ impl Server {
if let Err(e) = hook {
eprintln!("[ERR] event hook failed: {}", e);
}

if let Err(e) = thread.join() {
eprintln!("[ERR] transceiver thread panicked: {:?}", e);
}
}
}

Expand Down

0 comments on commit a61c0e3

Please sign in to comment.