Skip to content

Commit

Permalink
Use return value of process_ready_command()
Browse files Browse the repository at this point in the history
Client thread should quit immediately if/when the manager thread sends
the Quit command while waiting for the Ready command. This was not so
critical because the client quits when its command loop times out too.
But this fix is necessary for correctness.
  • Loading branch information
sonertari committed Apr 3, 2020
1 parent 1cbae0e commit e33476a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ impl Client {
let mut failed = false;

// Manager will not start the tests until children reply the Ready command
self.base.process_ready_command(&mut failed);
let exit = self.base.process_ready_command(&mut failed);

if !failed {
if !exit && !failed {
if let Ok(tcp_stream) = self.connect_tcp_stream(&mut failed) {
self.base.configure_tcp_stream(&tcp_stream);

Expand Down
3 changes: 1 addition & 2 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,13 @@ impl Server {

let mut stream_id = 1;
let mut tcp_stream_trials = 0;
let mut exit;
let mut failed = false;

// nonblocking is necessary to get the next stream (connection)
server.set_nonblocking(true).unwrap();

// Manager will not start the tests until children reply the Ready command
exit = self.base.process_ready_command(&mut failed);
let mut exit = self.base.process_ready_command(&mut failed);

if !exit && !failed {
self.base.cmd_trials = 0;
Expand Down
1 change: 1 addition & 0 deletions src/testend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ impl TestEndBase {
if e == CommandError::Fail {
*failed = true;
} else if e == CommandError::Disconnect {
// Actually CommandError::Disconnect error is never set while processing the ready command
break false;
}
break true;
Expand Down

0 comments on commit e33476a

Please sign in to comment.