Skip to content

Commit

Permalink
safeguard against thread panick in edge case scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
Keksoj authored and FlorentinDUBOIS committed Jul 13, 2022
1 parent 53f6911 commit 5a62a49
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,11 +454,16 @@ impl Server {
server.channel.set_nonblocking(false);
let msg = server.channel.read_message();
debug!("got message: {:?}", msg);
server.channel.write_message(&ProxyResponse {
id: msg.unwrap().id,
status: ProxyResponseStatus::Ok,
data: None,
});

// it so happens that trying to upgrade a dead worker will bring no message
// which brings the whole main processe to crash because it unwraps a None
if msg.is_some() {
server.channel.write_message(&ProxyResponse {
id: msg.unwrap().id,
status: ProxyResponseStatus::Ok,
data: None,
});
}
server.channel.set_nonblocking(true);
}

Expand Down

0 comments on commit 5a62a49

Please sign in to comment.