1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-27 20:12:58 +01:00

fix switching to unavailable state for worker

This commit is contained in:
Nikolay Kim 2018-09-14 00:07:50 -07:00
parent ec7757f032
commit 9888c1c5e6

View File

@ -210,6 +210,7 @@ impl Future for Worker {
WorkerState::Unavailable(mut conns) => {
match self.check_readiness() {
Ok(true) => {
trace!("Serveice is available");
self.state = WorkerState::Available;
// process requests from wait queue
@ -227,10 +228,12 @@ impl Future for Worker {
)
}
Ok(false) => {
trace!("Serveice is unavailable");
self.state = WorkerState::Unavailable(conns);
return self.poll();
}
Err(idx) => {
trace!("Serveice failed, restarting");
self.state = WorkerState::Restarting(
idx,
self.factories[idx].create(),
@ -247,6 +250,7 @@ impl Future for Worker {
return Ok(Async::NotReady);
}
Err(idx) => {
trace!("Serveice failed, restarting");
self.state = WorkerState::Restarting(idx, self.factories[idx].create());
return self.poll();
}
@ -303,8 +307,8 @@ impl Future for Worker {
loop {
match self.rx.poll() {
// handle incoming tcp stream
Ok(Async::Ready(Some(WorkerCommand::Message(msg)))) => match self
.check_readiness()
Ok(Async::Ready(Some(WorkerCommand::Message(msg)))) => {
match self.check_readiness()
{
Ok(true) => {
let guard = self.conns.get();
@ -316,16 +320,21 @@ impl Future for Worker {
val
}),
);
continue
}
Ok(false) => {
trace!("Serveice is unsavailable");
self.availability.set(false);
self.state = WorkerState::Unavailable(vec![msg]);
}
Err(idx) => {
trace!("Serveice failed, restarting");
self.availability.set(false);
self.state =
WorkerState::Restarting(idx, self.factories[idx].create());
}
}
return self.poll();
},
// `StopWorker` message handler
Ok(Async::Ready(Some(WorkerCommand::Stop(graceful, tx)))) => {