mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-29 00:00:11 +02:00
Merge 'tokio-1.20.2' into 'tokio-1.21.x' (#5057)
This commit is contained in:
@@ -6,7 +6,7 @@ jobs:
|
|||||||
resource_class: arm.medium
|
resource_class: arm.medium
|
||||||
environment:
|
environment:
|
||||||
# Change to pin rust version
|
# Change to pin rust version
|
||||||
RUST_STABLE: stable
|
RUST_STABLE: 1.63.0
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
- run:
|
- run:
|
||||||
@@ -22,4 +22,4 @@ jobs:
|
|||||||
workflows:
|
workflows:
|
||||||
ci:
|
ci:
|
||||||
jobs:
|
jobs:
|
||||||
- test-arm
|
- test-arm
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
freebsd_instance:
|
freebsd_instance:
|
||||||
image: freebsd-12-3-release-amd64
|
image: freebsd-12-3-release-amd64
|
||||||
env:
|
env:
|
||||||
RUST_STABLE: stable
|
RUST_STABLE: 1.63.0
|
||||||
RUST_NIGHTLY: nightly-2022-03-21
|
RUST_NIGHTLY: nightly-2022-03-21
|
||||||
RUSTFLAGS: -D warnings
|
RUSTFLAGS: -D warnings
|
||||||
|
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ env:
|
|||||||
RUSTFLAGS: -Dwarnings
|
RUSTFLAGS: -Dwarnings
|
||||||
RUST_BACKTRACE: 1
|
RUST_BACKTRACE: 1
|
||||||
# Change to specific Rust release to pin
|
# Change to specific Rust release to pin
|
||||||
rust_stable: stable
|
rust_stable: 1.63.0
|
||||||
rust_nightly: nightly-2022-07-26
|
rust_nightly: nightly-2022-07-26
|
||||||
rust_clippy: 1.52.0
|
rust_clippy: 1.56.0
|
||||||
# When updating this, also update:
|
# When updating this, also update:
|
||||||
# - README.md
|
# - README.md
|
||||||
# - tokio/README.md
|
# - tokio/README.md
|
||||||
@@ -298,8 +298,9 @@ jobs:
|
|||||||
toolchain: ${{ env.rust_min }}
|
toolchain: ${{ env.rust_min }}
|
||||||
override: true
|
override: true
|
||||||
- uses: Swatinem/rust-cache@v1
|
- uses: Swatinem/rust-cache@v1
|
||||||
- name: "test --workspace --all-features"
|
- name: "test --all-features"
|
||||||
run: cargo check --workspace --all-features
|
run: cargo check --all-features
|
||||||
|
working-directory: tokio
|
||||||
|
|
||||||
minimal-versions:
|
minimal-versions:
|
||||||
name: minimal-versions
|
name: minimal-versions
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ env:
|
|||||||
RUSTFLAGS: -Dwarnings
|
RUSTFLAGS: -Dwarnings
|
||||||
RUST_BACKTRACE: 1
|
RUST_BACKTRACE: 1
|
||||||
# Change to specific Rust release to pin
|
# Change to specific Rust release to pin
|
||||||
rust_stable: stable
|
rust_stable: 1.63.0
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
loom:
|
loom:
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ env:
|
|||||||
RUSTFLAGS: -Dwarnings
|
RUSTFLAGS: -Dwarnings
|
||||||
RUST_BACKTRACE: 1
|
RUST_BACKTRACE: 1
|
||||||
# Change to specific Rust release to pin
|
# Change to specific Rust release to pin
|
||||||
rust_stable: stable
|
rust_stable: 1.63.0
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
stress-test:
|
stress-test:
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ serde_derive = "1.0"
|
|||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
httparse = "1.0"
|
httparse = "1.0"
|
||||||
httpdate = "1.0"
|
httpdate = "1.0"
|
||||||
once_cell = "1.5.2"
|
|
||||||
rand = "0.8.3"
|
rand = "0.8.3"
|
||||||
|
|
||||||
[target.'cfg(windows)'.dev-dependencies.winapi]
|
[target.'cfg(windows)'.dev-dependencies.winapi]
|
||||||
@@ -71,11 +70,6 @@ path = "udp-codec.rs"
|
|||||||
name = "tinyhttp"
|
name = "tinyhttp"
|
||||||
path = "tinyhttp.rs"
|
path = "tinyhttp.rs"
|
||||||
|
|
||||||
[[example]]
|
|
||||||
name = "custom-executor"
|
|
||||||
path = "custom-executor.rs"
|
|
||||||
|
|
||||||
|
|
||||||
[[example]]
|
[[example]]
|
||||||
name = "custom-executor-tokio-context"
|
name = "custom-executor-tokio-context"
|
||||||
path = "custom-executor-tokio-context.rs"
|
path = "custom-executor-tokio-context.rs"
|
||||||
|
|||||||
@@ -103,6 +103,13 @@ wasm32-wasi target is given unstable support for the `net` feature.
|
|||||||
[#4956]: https://github.com/tokio-rs/tokio/pull/4956
|
[#4956]: https://github.com/tokio-rs/tokio/pull/4956
|
||||||
[#4959]: https://github.com/tokio-rs/tokio/pull/4959
|
[#4959]: https://github.com/tokio-rs/tokio/pull/4959
|
||||||
|
|
||||||
|
# 1.20.2 (September 27, 2022)
|
||||||
|
|
||||||
|
This release removes the dependency on the `once_cell` crate to restore the MSRV
|
||||||
|
of the 1.20.x LTS release. ([#5048])
|
||||||
|
|
||||||
|
[#5048]: https://github.com/tokio-rs/tokio/pull/5048
|
||||||
|
|
||||||
# 1.20.1 (July 25, 2022)
|
# 1.20.1 (July 25, 2022)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
@@ -221,6 +228,13 @@ This release fixes a bug in `Notified::enable`. ([#4747])
|
|||||||
[#4729]: https://github.com/tokio-rs/tokio/pull/4729
|
[#4729]: https://github.com/tokio-rs/tokio/pull/4729
|
||||||
[#4739]: https://github.com/tokio-rs/tokio/pull/4739
|
[#4739]: https://github.com/tokio-rs/tokio/pull/4739
|
||||||
|
|
||||||
|
# 1.18.3 (September 27, 2022)
|
||||||
|
|
||||||
|
This release removes the dependency on the `once_cell` crate to restore the MSRV
|
||||||
|
of the 1.18.x LTS release. ([#5048])
|
||||||
|
|
||||||
|
[#5048]: https://github.com/tokio-rs/tokio/pull/5048
|
||||||
|
|
||||||
# 1.18.2 (May 5, 2022)
|
# 1.18.2 (May 5, 2022)
|
||||||
|
|
||||||
Add missing features for the `winapi` dependency. ([#4663])
|
Add missing features for the `winapi` dependency. ([#4663])
|
||||||
|
|||||||
+1
-4
@@ -63,7 +63,6 @@ net = [
|
|||||||
]
|
]
|
||||||
process = [
|
process = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"once_cell",
|
|
||||||
"libc",
|
"libc",
|
||||||
"mio/os-poll",
|
"mio/os-poll",
|
||||||
"mio/os-ext",
|
"mio/os-ext",
|
||||||
@@ -77,13 +76,12 @@ process = [
|
|||||||
"winapi/winnt",
|
"winapi/winnt",
|
||||||
]
|
]
|
||||||
# Includes basic task execution capabilities
|
# Includes basic task execution capabilities
|
||||||
rt = ["once_cell"]
|
rt = []
|
||||||
rt-multi-thread = [
|
rt-multi-thread = [
|
||||||
"num_cpus",
|
"num_cpus",
|
||||||
"rt",
|
"rt",
|
||||||
]
|
]
|
||||||
signal = [
|
signal = [
|
||||||
"once_cell",
|
|
||||||
"libc",
|
"libc",
|
||||||
"mio/os-poll",
|
"mio/os-poll",
|
||||||
"mio/net",
|
"mio/net",
|
||||||
@@ -112,7 +110,6 @@ pin-project-lite = "0.2.0"
|
|||||||
|
|
||||||
# Everything else is optional...
|
# Everything else is optional...
|
||||||
bytes = { version = "1.0.0", optional = true }
|
bytes = { version = "1.0.0", optional = true }
|
||||||
once_cell = { version = "1.5.2", optional = true }
|
|
||||||
memchr = { version = "2.2", optional = true }
|
memchr = { version = "2.2", optional = true }
|
||||||
mio = { version = "0.8.4", optional = true }
|
mio = { version = "0.8.4", optional = true }
|
||||||
num_cpus = { version = "1.8.0", optional = true }
|
num_cpus = { version = "1.8.0", optional = true }
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ impl<T> Mutex<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[cfg(all(feature = "parking_lot", not(all(loom, test)),))]
|
#[cfg(all(feature = "parking_lot", not(all(loom, test))))]
|
||||||
#[cfg_attr(docsrs, doc(cfg(all(feature = "parking_lot",))))]
|
#[cfg_attr(docsrs, doc(cfg(all(feature = "parking_lot",))))]
|
||||||
pub(crate) const fn const_new(t: T) -> Mutex<T> {
|
pub(crate) const fn const_new(t: T) -> Mutex<T> {
|
||||||
Mutex(PhantomData, parking_lot::const_mutex(t))
|
Mutex(PhantomData, parking_lot::const_mutex(t))
|
||||||
|
|||||||
@@ -34,10 +34,10 @@ use crate::process::kill::Kill;
|
|||||||
use crate::process::SpawnedChild;
|
use crate::process::SpawnedChild;
|
||||||
use crate::signal::unix::driver::Handle as SignalHandle;
|
use crate::signal::unix::driver::Handle as SignalHandle;
|
||||||
use crate::signal::unix::{signal, Signal, SignalKind};
|
use crate::signal::unix::{signal, Signal, SignalKind};
|
||||||
|
use crate::util::once_cell::OnceCell;
|
||||||
|
|
||||||
use mio::event::Source;
|
use mio::event::Source;
|
||||||
use mio::unix::SourceFd;
|
use mio::unix::SourceFd;
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
@@ -64,25 +64,29 @@ impl Kill for StdChild {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static ORPHAN_QUEUE: Lazy<OrphanQueueImpl<StdChild>> = Lazy::new(OrphanQueueImpl::new);
|
fn get_orphan_queue() -> &'static OrphanQueueImpl<StdChild> {
|
||||||
|
static ORPHAN_QUEUE: OnceCell<OrphanQueueImpl<StdChild>> = OnceCell::new();
|
||||||
|
|
||||||
|
ORPHAN_QUEUE.get(OrphanQueueImpl::new)
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) struct GlobalOrphanQueue;
|
pub(crate) struct GlobalOrphanQueue;
|
||||||
|
|
||||||
impl fmt::Debug for GlobalOrphanQueue {
|
impl fmt::Debug for GlobalOrphanQueue {
|
||||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
ORPHAN_QUEUE.fmt(fmt)
|
get_orphan_queue().fmt(fmt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GlobalOrphanQueue {
|
impl GlobalOrphanQueue {
|
||||||
fn reap_orphans(handle: &SignalHandle) {
|
fn reap_orphans(handle: &SignalHandle) {
|
||||||
ORPHAN_QUEUE.reap_orphans(handle)
|
get_orphan_queue().reap_orphans(handle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OrphanQueue<StdChild> for GlobalOrphanQueue {
|
impl OrphanQueue<StdChild> for GlobalOrphanQueue {
|
||||||
fn push_orphan(&self, orphan: StdChild) {
|
fn push_orphan(&self, orphan: StdChild) {
|
||||||
ORPHAN_QUEUE.push_orphan(orphan)
|
get_orphan_queue().push_orphan(orphan)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -508,11 +508,17 @@ impl Id {
|
|||||||
|
|
||||||
cfg_not_has_atomic_u64! {
|
cfg_not_has_atomic_u64! {
|
||||||
pub(crate) fn next() -> Self {
|
pub(crate) fn next() -> Self {
|
||||||
use once_cell::sync::Lazy;
|
use crate::util::once_cell::OnceCell;
|
||||||
use crate::loom::sync::Mutex;
|
use crate::loom::sync::Mutex;
|
||||||
|
|
||||||
static NEXT_ID: Lazy<Mutex<u64>> = Lazy::new(|| Mutex::new(1));
|
fn init_next_id() -> Mutex<u64> {
|
||||||
let mut lock = NEXT_ID.lock();
|
Mutex::new(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
static NEXT_ID: OnceCell<Mutex<u64>> = OnceCell::new();
|
||||||
|
|
||||||
|
let next_id = NEXT_ID.get(init_next_id);
|
||||||
|
let mut lock = next_id.lock();
|
||||||
let id = *lock;
|
let id = *lock;
|
||||||
*lock += 1;
|
*lock += 1;
|
||||||
Self(id)
|
Self(id)
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
#![allow(clippy::unit_arg)]
|
#![allow(clippy::unit_arg)]
|
||||||
|
|
||||||
use crate::signal::os::{OsExtraData, OsStorage};
|
use crate::signal::os::{OsExtraData, OsStorage};
|
||||||
|
|
||||||
use crate::sync::watch;
|
use crate::sync::watch;
|
||||||
|
use crate::util::once_cell::OnceCell;
|
||||||
|
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
use std::ops;
|
use std::ops;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
@@ -152,19 +151,25 @@ impl Globals {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn globals_init() -> Globals
|
||||||
|
where
|
||||||
|
OsExtraData: 'static + Send + Sync + Init,
|
||||||
|
OsStorage: 'static + Send + Sync + Init,
|
||||||
|
{
|
||||||
|
Globals {
|
||||||
|
extra: OsExtraData::init(),
|
||||||
|
registry: Registry::new(OsStorage::init()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn globals() -> Pin<&'static Globals>
|
pub(crate) fn globals() -> Pin<&'static Globals>
|
||||||
where
|
where
|
||||||
OsExtraData: 'static + Send + Sync + Init,
|
OsExtraData: 'static + Send + Sync + Init,
|
||||||
OsStorage: 'static + Send + Sync + Init,
|
OsStorage: 'static + Send + Sync + Init,
|
||||||
{
|
{
|
||||||
static GLOBALS: Lazy<Pin<Box<Globals>>> = Lazy::new(|| {
|
static GLOBALS: OnceCell<Globals> = OnceCell::new();
|
||||||
Box::pin(Globals {
|
|
||||||
extra: OsExtraData::init(),
|
|
||||||
registry: Registry::new(OsStorage::init()),
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
GLOBALS.as_ref()
|
Pin::new(GLOBALS.get(globals_init))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(test, not(loom)))]
|
#[cfg(all(test, not(loom)))]
|
||||||
|
|||||||
@@ -6,6 +6,15 @@ cfg_io_driver! {
|
|||||||
#[cfg(feature = "rt")]
|
#[cfg(feature = "rt")]
|
||||||
pub(crate) mod atomic_cell;
|
pub(crate) mod atomic_cell;
|
||||||
|
|
||||||
|
cfg_has_atomic_u64! {
|
||||||
|
#[cfg(any(feature = "signal", all(unix, feature = "process")))]
|
||||||
|
pub(crate) mod once_cell;
|
||||||
|
}
|
||||||
|
cfg_not_has_atomic_u64! {
|
||||||
|
#[cfg(any(feature = "rt", feature = "signal", all(unix, feature = "process")))]
|
||||||
|
pub(crate) mod once_cell;
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(any(
|
#[cfg(any(
|
||||||
// io driver uses `WakeList` directly
|
// io driver uses `WakeList` directly
|
||||||
feature = "net",
|
feature = "net",
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
#![cfg_attr(loom, allow(dead_code))]
|
||||||
|
use std::cell::UnsafeCell;
|
||||||
|
use std::mem::MaybeUninit;
|
||||||
|
use std::sync::Once;
|
||||||
|
|
||||||
|
pub(crate) struct OnceCell<T> {
|
||||||
|
once: Once,
|
||||||
|
value: UnsafeCell<MaybeUninit<T>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl<T: Send + Sync> Send for OnceCell<T> {}
|
||||||
|
unsafe impl<T: Send + Sync> Sync for OnceCell<T> {}
|
||||||
|
|
||||||
|
impl<T> OnceCell<T> {
|
||||||
|
pub(crate) const fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
once: Once::new(),
|
||||||
|
value: UnsafeCell::new(MaybeUninit::uninit()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get the value inside this cell, intiailizing it using the provided
|
||||||
|
/// function if necessary.
|
||||||
|
///
|
||||||
|
/// If the `init` closure panics, then the `OnceCell` is poisoned and all
|
||||||
|
/// future calls to `get` will panic.
|
||||||
|
#[inline]
|
||||||
|
pub(crate) fn get(&self, init: fn() -> T) -> &T {
|
||||||
|
if !self.once.is_completed() {
|
||||||
|
self.do_init(init);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Safety: The `std::sync::Once` guarantees that we can only reach this
|
||||||
|
// line if a `call_once` closure has been run exactly once and without
|
||||||
|
// panicking. Thus, the value is not uninitialized.
|
||||||
|
//
|
||||||
|
// There is also no race because the only `&self` method that modifies
|
||||||
|
// `value` is `do_init`, but if the `call_once` closure is still
|
||||||
|
// running, then no thread has gotten past the `call_once`.
|
||||||
|
unsafe { &*(self.value.get() as *const T) }
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cold]
|
||||||
|
fn do_init(&self, init: fn() -> T) {
|
||||||
|
let value_ptr = self.value.get() as *mut T;
|
||||||
|
|
||||||
|
self.once.call_once(|| {
|
||||||
|
let set_to = init();
|
||||||
|
|
||||||
|
// Safety: The `std::sync::Once` guarantees that this initialization
|
||||||
|
// will run at most once, and that no thread can get past the
|
||||||
|
// `call_once` until it has run exactly once. Thus, we have
|
||||||
|
// exclusive access to `value`.
|
||||||
|
unsafe {
|
||||||
|
std::ptr::write(value_ptr, set_to);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> Drop for OnceCell<T> {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
if self.once.is_completed() {
|
||||||
|
let value_ptr = self.value.get() as *mut T;
|
||||||
|
unsafe {
|
||||||
|
std::ptr::drop_in_place(value_ptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user