Do not process data in Dispatcher from read buffer after disconnect

This commit is contained in:
Nikolay Kim 2023-11-21 00:56:09 +06:00
parent 9db4f21d71
commit 096aae2732
2 changed files with 53 additions and 42 deletions

View file

@ -4,6 +4,8 @@
* Remove slow frame timer if service is not ready * Remove slow frame timer if service is not ready
* Do not process data in Dispatcher from read buffer after disconnect
## [0.3.8] - 2023-11-17 ## [0.3.8] - 2023-11-17
* Remove useless logs * Remove useless logs

View file

@ -324,7 +324,13 @@ where
let item = match ready!(slf.poll_service(cx)) { let item = match ready!(slf.poll_service(cx)) {
PollService::Ready => { PollService::Ready => {
// decode incoming bytes if buffer is ready // decode incoming bytes if buffer is ready
match slf.shared.io.poll_recv_decode(&slf.shared.codec, cx) { if slf.shared.io.is_closed() {
log::trace!("io has been closed, stop dispatcher");
slf.st = DispatcherState::Stop;
DispatchItem::Disconnect(None)
} else {
match slf.shared.io.poll_recv_decode(&slf.shared.codec, cx)
{
Ok(decoded) => { Ok(decoded) => {
slf.update_timer(&decoded); slf.update_timer(&decoded);
if let Some(el) = decoded.item { if let Some(el) = decoded.item {
@ -334,7 +340,9 @@ where
} }
} }
Err(RecvError::KeepAlive) => { Err(RecvError::KeepAlive) => {
log::trace!("keep-alive error, stopping dispatcher"); log::trace!(
"keep-alive error, stopping dispatcher"
);
slf.st = DispatcherState::Stop; slf.st = DispatcherState::Stop;
if slf.flags.contains(Flags::READ_TIMEOUT) { if slf.flags.contains(Flags::READ_TIMEOUT) {
DispatchItem::ReadTimeout DispatchItem::ReadTimeout
@ -370,6 +378,7 @@ where
} }
} }
} }
}
PollService::Item(item) => item, PollService::Item(item) => item,
PollService::Continue => continue, PollService::Continue => continue,
}; };
@ -492,8 +501,8 @@ where
// remove all timers // remove all timers
if self.flags.contains(Flags::READ_TIMEOUT) { if self.flags.contains(Flags::READ_TIMEOUT) {
self.flags.remove(Flags::READ_TIMEOUT); self.flags.remove(Flags::READ_TIMEOUT);
self.shared.io.stop_timer();
} }
self.shared.io.stop_timer();
match ready!(self.shared.io.poll_read_pause(cx)) { match ready!(self.shared.io.poll_read_pause(cx)) {
IoStatusUpdate::KeepAlive => { IoStatusUpdate::KeepAlive => {