Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix KeepAlive timeout handling in default dispatcher #351

Merged
merged 2 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ntex-io/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changes

## [1.1.0] - 2024-05-01

* Add IoRef::notify_timeout() helper method

* Fix KeepAlive timeout handling in default dispatcher

## [1.0.2] - 2024-03-31

* Add IoRef::is_wr_backpressure() method
Expand Down
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 = "1.0.2"
version = "1.1.0"
authors = ["ntex contributors <team@ntex.rs>"]
description = "Utilities for encoding and decoding frames"
keywords = ["network", "framework", "async", "futures"]
Expand Down
18 changes: 11 additions & 7 deletions ntex-io/src/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,15 +575,19 @@
self.shared.io.tag()
);
}
return Err(DispatchItem::ReadTimeout);
Err(DispatchItem::ReadTimeout)
} else {
Ok(())

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

View check run for this annotation

Codecov / codecov/patch

ntex-io/src/dispatcher.rs#L580

Added line #L580 was not covered by tests
}
} else if self.flags.contains(Flags::KA_TIMEOUT) {
log::trace!(
"{}: Keep-alive error, stopping dispatcher",
self.shared.io.tag()

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

View check run for this annotation

Codecov / codecov/patch

ntex-io/src/dispatcher.rs#L584-L585

Added lines #L584 - L585 were not covered by tests
);
Err(DispatchItem::KeepAliveTimeout)
} else {
Ok(())

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

View check run for this annotation

Codecov / codecov/patch

ntex-io/src/dispatcher.rs#L589

Added line #L589 was not covered by tests
}

log::trace!(
"{}: Keep-alive error, stopping dispatcher",
self.shared.io.tag()
);
Err(DispatchItem::KeepAliveTimeout)
}
}

Expand Down
3 changes: 1 addition & 2 deletions ntex-io/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,12 @@ impl IoState {
}

pub(super) fn notify_timeout(&self) {
log::trace!("{}: Timeout, notify dispatcher", self.tag.get());

let mut flags = self.flags.get();
if !flags.contains(Flags::DSP_TIMEOUT) {
flags.insert(Flags::DSP_TIMEOUT);
self.flags.set(flags);
self.dispatch_task.wake();
log::trace!("{}: Timer, notify dispatcher", self.tag.get());
}
}

Expand Down
6 changes: 6 additions & 0 deletions ntex-io/src/ioref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,12 @@
self.0.timeout.get()
}

#[inline]
/// wakeup dispatcher and send keep-alive error
pub fn notify_timeout(&self) {
self.0.notify_timeout()
}

Check warning on line 235 in ntex-io/src/ioref.rs

View check run for this annotation

Codecov / codecov/patch

ntex-io/src/ioref.rs#L233-L235

Added lines #L233 - L235 were not covered by tests

#[inline]
/// Start timer
pub fn start_timer(&self, timeout: Seconds) -> timer::TimerHandle {
Expand Down
2 changes: 1 addition & 1 deletion ntex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ ntex-bytes = "0.1.25"
ntex-server = "1.0.5"
ntex-h2 = "0.5.4"
ntex-rt = "0.4.12"
ntex-io = "1.0.1"
ntex-io = "1.1.0"
ntex-net = "1.0.1"
ntex-tls = "1.1.0"

Expand Down
Loading