Browse Source

Drain result channel during server execution.

wip
Titouan Rigoudy 4 years ago
parent
commit
74ce0ac425
1 changed files with 10 additions and 2 deletions
  1. +10
    -2
      src/proto/server/testing.rs

+ 10
- 2
src/proto/server/testing.rs View File

@ -296,9 +296,9 @@ impl Server {
let (stream, peer_address) = result?;
self.spawn_handler(stream, peer_address);
},
// If shutdown_rx's sender is dropped and we receive an error, we take
// that as a signal to shut down immediately too.
result = &mut self.shutdown_rx => {
// If shutdown_rx's sender is dropped and we receive an error, we take
// that as a signal to shut down immediately too.
match result.unwrap_or(ShutdownType::Immediate) {
ShutdownType::LameDuck => break,
ShutdownType::Immediate => {
@ -308,6 +308,14 @@ impl Server {
break
}
}
},
optional_result = self.result_rx.recv() => {
// We can never exhaust the result channel because we hold onto a
// sender in `self.result_tx`.
let result = optional_result.unwrap();
// Return an error if a handler returns an error.
result?;
}
);
}


Loading…
Cancel
Save