Merge branch 'tokio-1.0.x' into 'tokio-1.1.x'

This commit is contained in:
Carl Lerche 2021-01-28 20:23:50 -08:00
commit 085f819f28
No known key found for this signature in database
GPG Key ID: AA14CE6F061D8F7A
8 changed files with 88 additions and 5 deletions

View File

@ -28,6 +28,7 @@ jobs:
- clippy - clippy
- docs - docs
- loom - loom
- valgrind
steps: steps:
- run: exit 0 - run: exit 0
@ -67,6 +68,28 @@ jobs:
run: cargo hack test --each-feature run: cargo hack test --each-feature
working-directory: tests-build working-directory: tests-build
valgrind:
name: valgrind
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Rust
run: rustup update stable
- name: Install Valgrind
run: |
sudo apt-get update -y
sudo apt-get install -y valgrind
# Compile tests
- name: cargo build
run: cargo build --features rt-net --bin test-mem
working-directory: tests-integration
# Run with valgrind
- name: Run valgrind
run: valgrind --leak-check=full --show-leak-kinds=all ./target/debug/test-mem
test-unstable: test-unstable:
name: test tokio full --unstable name: test tokio full --unstable
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}

View File

@ -5,7 +5,17 @@ authors = ["Tokio Contributors <team@tokio.rs>"]
edition = "2018" edition = "2018"
publish = false publish = false
[[bin]]
name = "test-cat"
[[bin]]
name = "test-mem"
required-features = ["rt-net"]
[features] [features]
# For mem check
rt-net = ["tokio/rt", "tokio/rt-multi-thread", "tokio/net"]
full = [ full = [
"macros", "macros",
"rt", "rt",
@ -23,6 +33,4 @@ rt-multi-thread = ["rt", "tokio/rt-multi-thread"]
tokio = { path = "../tokio" } tokio = { path = "../tokio" }
tokio-test = { path = "../tokio-test", optional = true } tokio-test = { path = "../tokio-test", optional = true }
doc-comment = "0.3.1" doc-comment = "0.3.1"
[dev-dependencies]
futures = { version = "0.3.0", features = ["async-await"] } futures = { version = "0.3.0", features = ["async-await"] }

View File

@ -0,0 +1,21 @@
use futures::future::poll_fn;
fn main() {
let rt = tokio::runtime::Builder::new_multi_thread()
.worker_threads(1)
.enable_io()
.build()
.unwrap();
rt.block_on(async {
let listener = tokio::net::TcpListener::bind("0.0.0.0:0").await.unwrap();
tokio::spawn(async move {
loop {
poll_fn(|cx| listener.poll_accept(cx)).await.unwrap();
}
});
});
std::thread::sleep(std::time::Duration::from_millis(50));
drop(rt);
}

View File

@ -1,3 +1,10 @@
# 1.1.1 (January 29, 2021)
Forward ports 1.0.3 fix.
### Fixed
- io: memory leak during shutdown (#3477).
# 1.1.0 (January 22, 2020) # 1.1.0 (January 22, 2020)
### Added ### Added
@ -48,6 +55,11 @@
[#3457]: https://github.com/tokio-rs/tokio/pull/3457 [#3457]: https://github.com/tokio-rs/tokio/pull/3457
[#3458]: https://github.com/tokio-rs/tokio/pull/3458 [#3458]: https://github.com/tokio-rs/tokio/pull/3458
# 1.0.3 (January 28, 2020)
### Fixed
- io: memory leak during shutdown (#3477).
# 1.0.2 (January 14, 2020) # 1.0.2 (January 14, 2020)
### Fixed ### Fixed

View File

@ -8,12 +8,12 @@ name = "tokio"
# - README.md # - README.md
# - Update CHANGELOG.md. # - Update CHANGELOG.md.
# - Create "v1.0.x" git tag. # - Create "v1.0.x" git tag.
version = "1.1.0" version = "1.1.1"
edition = "2018" edition = "2018"
authors = ["Tokio Contributors <team@tokio.rs>"] authors = ["Tokio Contributors <team@tokio.rs>"]
license = "MIT" license = "MIT"
readme = "README.md" readme = "README.md"
documentation = "https://docs.rs/tokio/1.1.0/tokio/" documentation = "https://docs.rs/tokio/1.1.1/tokio/"
repository = "https://github.com/tokio-rs/tokio" repository = "https://github.com/tokio-rs/tokio"
homepage = "https://tokio.rs" homepage = "https://tokio.rs"
description = """ description = """

View File

@ -205,6 +205,19 @@ impl Registration {
} }
} }
impl Drop for Registration {
fn drop(&mut self) {
// It is possible for a cycle to be created between wakers stored in
// `ScheduledIo` instances and `Arc<driver::Inner>`. To break this
// cycle, wakers are cleared. This is an imperfect solution as it is
// possible to store a `Registration` in a waker. In this case, the
// cycle would remain.
//
// See tokio-rs/tokio#3481 for more details.
self.shared.clear_wakers();
}
}
fn gone() -> io::Error { fn gone() -> io::Error {
io::Error::new(io::ErrorKind::Other, "IO driver has terminated") io::Error::new(io::ErrorKind::Other, "IO driver has terminated")
} }

View File

@ -355,6 +355,12 @@ impl ScheduledIo {
// result isn't important // result isn't important
let _ = self.set_readiness(None, Tick::Clear(event.tick), |curr| curr - mask_no_closed); let _ = self.set_readiness(None, Tick::Clear(event.tick), |curr| curr - mask_no_closed);
} }
pub(crate) fn clear_wakers(&self) {
let mut waiters = self.waiters.lock();
waiters.reader.take();
waiters.writer.take();
}
} }
impl Drop for ScheduledIo { impl Drop for ScheduledIo {

View File

@ -1,4 +1,4 @@
#![doc(html_root_url = "https://docs.rs/tokio/1.1.0")] #![doc(html_root_url = "https://docs.rs/tokio/1.1.1")]
#![allow( #![allow(
clippy::cognitive_complexity, clippy::cognitive_complexity,
clippy::large_enum_variant, clippy::large_enum_variant,