Skip to content

Commit

Permalink
Periodically check readiness
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed Nov 4, 2024
1 parent 48ce0ea commit 9ae3d06
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ntex-io/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ntex-io"
version = "2.8.0"
version = "2.8.1"
authors = ["ntex contributors <team@ntex.rs>"]
description = "Utilities for encoding and decoding frames"
keywords = ["network", "framework", "async", "futures"]
Expand Down
7 changes: 6 additions & 1 deletion ntex-io/src/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ use crate::{Decoded, DispatchItem, IoBoxed, IoStatusUpdate, RecvError};

type Response<U> = <U as Encoder>::Item;

const READY_COUNT: u8 = 32;

#[derive(Clone, Debug)]
/// Shared dispatcher configuration
pub struct DispatcherConfig(Rc<DispatcherConfigInner>);
Expand Down Expand Up @@ -146,6 +148,7 @@ where
shared: Rc<DispatcherShared<S, U>>,
response: Option<PipelineCall<S, DispatchItem<U>>>,
cfg: DispatcherConfig,
ready_count: u8,
read_remains: u32,
read_remains_prev: u32,
read_max_timeout: Seconds,
Expand Down Expand Up @@ -473,7 +476,8 @@ where
fn poll_service(&mut self, cx: &mut Context<'_>) -> Poll<PollService<U>> {

Check warning on line 476 in ntex-io/src/dispatcher.rs

View workflow job for this annotation

GitHub Actions / Rustfmt (stable)

Diff in /home/runner/work/ntex/ntex/ntex-io/src/dispatcher.rs
// check service readiness
if self.flags.contains(Flags::READY) {
if self.shared.service.poll_not_ready(cx).is_pending() {
if self.ready_count != 0 && self.shared.service.poll_not_ready(cx).is_pending() {
self.ready_count -= 1;
return Poll::Ready(self.check_error());
}
self.flags.remove(Flags::READY);
Expand All @@ -482,6 +486,7 @@ where
// wait until service becomes ready
match self.shared.service.poll_ready(cx) {
Poll::Ready(Ok(_)) => {
self.ready_count = READY_COUNT;
self.flags.insert(Flags::READY);
Poll::Ready(self.check_error())
}
Expand Down

0 comments on commit 9ae3d06

Please sign in to comment.