Add handle check with enabling worker handle

This commit is contained in:
fakeshadow 2021-04-26 00:36:37 +08:00
parent 1033f5aa67
commit c0208cc69e
1 changed files with 7 additions and 2 deletions

View File

@ -259,7 +259,13 @@ impl Accept {
while let task::Poll::Ready(msg) = self.waker_rx.poll_recv(cx) { while let task::Poll::Ready(msg) = self.waker_rx.poll_recv(cx) {
match msg { match msg {
Some(WakerInterest::WorkerAvailable(idx)) => { Some(WakerInterest::WorkerAvailable(idx)) => {
// Check if Accept have handle with the same index.
// If not this worker is restarting and it's handle is not arrived yet.
// (Happen in WakerInterest::Worker variant)
let have_handle = self.handles.iter().any(|handle| handle.idx() == idx);
if have_handle {
self.avail.set_available(idx, true); self.avail.set_available(idx, true);
}
if !self.paused { if !self.paused {
self.accept_all(); self.accept_all();
@ -380,7 +386,6 @@ impl Accept {
Err(c) => conn = c, Err(c) => conn = c,
} }
} else { } else {
self.avail.set_available(idx, false);
self.set_next(); self.set_next();
if !self.avail.available() { if !self.avail.available() {