mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-09 00:00:08 +02:00
Merge 'tokio-1.21.1' into 'master'
This commit is contained in:
@@ -56,7 +56,7 @@ Make sure you activated the full features of the tokio crate on Cargo.toml:
|
|||||||
|
|
||||||
```toml
|
```toml
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tokio = { version = "1.21.0", features = ["full"] }
|
tokio = { version = "1.21.1", features = ["full"] }
|
||||||
```
|
```
|
||||||
Then, on your main.rs:
|
Then, on your main.rs:
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,13 @@
|
|||||||
|
# 1.21.1 (September 13, 2022)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- net: fix dependency resolution for socket2 ([#5000])
|
||||||
|
- task: ignore failure to set TLS in `LocalSet` Drop ([#4976])
|
||||||
|
|
||||||
|
[#4976]: https://github.com/tokio-rs/tokio/pull/4976
|
||||||
|
[#5000]: https://github.com/tokio-rs/tokio/pull/5000
|
||||||
|
|
||||||
# 1.21.0 (September 2, 2022)
|
# 1.21.0 (September 2, 2022)
|
||||||
|
|
||||||
This release is the first release of Tokio to intentionally support WASM. The
|
This release is the first release of Tokio to intentionally support WASM. The
|
||||||
|
|||||||
+4
-3
@@ -6,7 +6,7 @@ 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.21.0"
|
version = "1.21.1"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
rust-version = "1.49"
|
rust-version = "1.49"
|
||||||
authors = ["Tokio Contributors <[email protected]>"]
|
authors = ["Tokio Contributors <[email protected]>"]
|
||||||
@@ -51,6 +51,7 @@ net = [
|
|||||||
"mio/os-poll",
|
"mio/os-poll",
|
||||||
"mio/os-ext",
|
"mio/os-ext",
|
||||||
"mio/net",
|
"mio/net",
|
||||||
|
"socket2",
|
||||||
"winapi/fileapi",
|
"winapi/fileapi",
|
||||||
"winapi/handleapi",
|
"winapi/handleapi",
|
||||||
"winapi/namedpipeapi",
|
"winapi/namedpipeapi",
|
||||||
@@ -58,7 +59,7 @@ net = [
|
|||||||
"winapi/winnt",
|
"winapi/winnt",
|
||||||
"winapi/minwindef",
|
"winapi/minwindef",
|
||||||
"winapi/accctrl",
|
"winapi/accctrl",
|
||||||
"winapi/aclapi"
|
"winapi/aclapi",
|
||||||
]
|
]
|
||||||
process = [
|
process = [
|
||||||
"bytes",
|
"bytes",
|
||||||
@@ -118,7 +119,7 @@ num_cpus = { version = "1.8.0", optional = true }
|
|||||||
parking_lot = { version = "0.12.0", optional = true }
|
parking_lot = { version = "0.12.0", optional = true }
|
||||||
|
|
||||||
[target.'cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))'.dependencies]
|
[target.'cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))'.dependencies]
|
||||||
socket2 = { version = "0.4.4", features = [ "all" ] }
|
socket2 = { version = "0.4.4", optional = true, features = [ "all" ] }
|
||||||
|
|
||||||
# Currently unstable. The API exposed by these features may be broken at any time.
|
# Currently unstable. The API exposed by these features may be broken at any time.
|
||||||
# Requires `--cfg tokio_unstable` to enable.
|
# Requires `--cfg tokio_unstable` to enable.
|
||||||
|
|||||||
+1
-1
@@ -56,7 +56,7 @@ Make sure you activated the full features of the tokio crate on Cargo.toml:
|
|||||||
|
|
||||||
```toml
|
```toml
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tokio = { version = "1.21.0", features = ["full"] }
|
tokio = { version = "1.21.1", features = ["full"] }
|
||||||
```
|
```
|
||||||
Then, on your main.rs:
|
Then, on your main.rs:
|
||||||
|
|
||||||
|
|||||||
+32
-1
@@ -635,6 +635,37 @@ impl LocalSet {
|
|||||||
f()
|
f()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// This method is like `with`, but it just calls `f` without setting the thread-local if that
|
||||||
|
/// fails.
|
||||||
|
fn with_if_possible<T>(&self, f: impl FnOnce() -> T) -> T {
|
||||||
|
let mut f = Some(f);
|
||||||
|
|
||||||
|
let res = CURRENT.try_with(|ctx| {
|
||||||
|
struct Reset<'a> {
|
||||||
|
ctx_ref: &'a RcCell<Context>,
|
||||||
|
val: Option<Rc<Context>>,
|
||||||
|
}
|
||||||
|
impl<'a> Drop for Reset<'a> {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
self.ctx_ref.replace(self.val.take());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let old = ctx.replace(Some(self.context.clone()));
|
||||||
|
|
||||||
|
let _reset = Reset {
|
||||||
|
ctx_ref: ctx,
|
||||||
|
val: old,
|
||||||
|
};
|
||||||
|
|
||||||
|
(f.take().unwrap())()
|
||||||
|
});
|
||||||
|
|
||||||
|
match res {
|
||||||
|
Ok(res) => res,
|
||||||
|
Err(_access_error) => (f.take().unwrap())(),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg_unstable! {
|
cfg_unstable! {
|
||||||
@@ -746,7 +777,7 @@ impl Default for LocalSet {
|
|||||||
|
|
||||||
impl Drop for LocalSet {
|
impl Drop for LocalSet {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
self.with(|| {
|
self.with_if_possible(|| {
|
||||||
// Shut down all tasks in the LocalOwnedTasks and close it to
|
// Shut down all tasks in the LocalOwnedTasks and close it to
|
||||||
// prevent new tasks from ever being added.
|
// prevent new tasks from ever being added.
|
||||||
self.context.owned.close_and_shutdown_all();
|
self.context.owned.close_and_shutdown_all();
|
||||||
|
|||||||
@@ -311,6 +311,27 @@ fn join_local_future_elsewhere() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tests for <https://github.com/tokio-rs/tokio/issues/4973>
|
||||||
|
#[cfg(not(tokio_wasi))] // Wasi doesn't support threads
|
||||||
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
|
async fn localset_in_thread_local() {
|
||||||
|
thread_local! {
|
||||||
|
static LOCAL_SET: LocalSet = LocalSet::new();
|
||||||
|
}
|
||||||
|
|
||||||
|
// holds runtime thread until end of main fn.
|
||||||
|
let (_tx, rx) = oneshot::channel::<()>();
|
||||||
|
let handle = tokio::runtime::Handle::current();
|
||||||
|
|
||||||
|
std::thread::spawn(move || {
|
||||||
|
LOCAL_SET.with(|local_set| {
|
||||||
|
handle.block_on(local_set.run_until(async move {
|
||||||
|
let _ = rx.await;
|
||||||
|
}))
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn drop_cancels_tasks() {
|
fn drop_cancels_tasks() {
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|||||||
Reference in New Issue
Block a user