Skip to content

Commit

Permalink
feat(swarm): Show task spawn paths in tokio-console
Browse files Browse the repository at this point in the history
This PR adds `#[track_caller]` on all `spawn` wrappers.

Pull-Request: #5465.
  • Loading branch information
oblique authored Jul 4, 2024
1 parent 36c2f94 commit 693d7b7
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ libp2p-gossipsub = { version = "0.46.2", path = "protocols/gossipsub" }
libp2p-identify = { version = "0.45.0", path = "protocols/identify" }
libp2p-identity = { version = "0.2.9" }
libp2p-kad = { version = "0.46.0", path = "protocols/kad" }
libp2p-mdns = { version = "0.45.1", path = "protocols/mdns" }
libp2p-mdns = { version = "0.45.2", path = "protocols/mdns" }
libp2p-memory-connection-limits = { version = "0.2.0", path = "misc/memory-connection-limits" }
libp2p-metrics = { version = "0.14.2", path = "misc/metrics" }
libp2p-mplex = { version = "0.41.0", path = "muxers/mplex" }
Expand Down
5 changes: 5 additions & 0 deletions protocols/mdns/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.45.2

- Add `#[track_caller]` on all `spawn` wrappers.
See [PR 5465](https://github.com/libp2p/rust-libp2p/pull/5465).

## 0.45.1

- Ensure `Multiaddr` handled and returned by `Behaviour` are `/p2p` terminated.
Expand Down
2 changes: 1 addition & 1 deletion protocols/mdns/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "libp2p-mdns"
edition = "2021"
rust-version = { workspace = true }
version = "0.45.1"
version = "0.45.2"
description = "Implementation of the libp2p mDNS discovery method"
authors = ["Parity Technologies <[email protected]>"]
license = "MIT"
Expand Down
1 change: 1 addition & 0 deletions protocols/mdns/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pub trait Provider: 'static {
/// Create a new instance of the `IfWatcher` type.
fn new_watcher() -> Result<Self::Watcher, std::io::Error>;

#[track_caller]
fn spawn(task: impl Future<Output = ()> + Send + 'static) -> Self::TaskHandle;
}

Expand Down
2 changes: 2 additions & 0 deletions swarm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

- Use `web-time` instead of `instant`.
See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347).
- Add `#[track_caller]` on all `spawn` wrappers.
See [PR 5465](https://github.com/libp2p/rust-libp2p/pull/5465).

## 0.44.2

Expand Down
1 change: 1 addition & 0 deletions swarm/src/connection/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ impl ExecSwitch {
}
}

#[track_caller]
fn spawn(&mut self, task: impl Future<Output = ()> + Send + 'static) {
let task = task.boxed();

Expand Down
1 change: 1 addition & 0 deletions swarm/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use std::{future::Future, pin::Pin};
/// > about running `Future`s on a separate task.
pub trait Executor {
/// Run the given future in the background until it ends.
#[track_caller]
fn exec(&self, future: Pin<Box<dyn Future<Output = ()> + Send>>);
}

Expand Down

0 comments on commit 693d7b7

Please sign in to comment.