Skip to content

Commit 144be1f

Browse files
fix(stream): garbage-collect deregistered streams in Shared::accept
Related #5963 Fixes #5963 As per the discussion in the comments of the issue, I have modified `Shared::accept` to remove deregistered inbound protocols similar to what `Shared::supported_inbound_protocols` does, in order to potentially fix the problem of dropping IncomingStreams does not deregister inbound protocol Pull-Request: #5999.
1 parent bec08cc commit 144be1f

File tree

6 files changed

+13
-4
lines changed

6 files changed

+13
-4
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ libp2p-relay = { version = "0.20.0", path = "protocols/relay" }
101101
libp2p-rendezvous = { version = "0.16.1", path = "protocols/rendezvous" }
102102
libp2p-request-response = { version = "0.28.1", path = "protocols/request-response" }
103103
libp2p-server = { version = "0.12.7", path = "misc/server" }
104-
libp2p-stream = { version = "0.3.0-alpha", path = "protocols/stream" }
104+
libp2p-stream = { version = "0.3.0-alpha.1", path = "protocols/stream" }
105105
libp2p-swarm = { version = "0.47.0", path = "swarm" }
106106
libp2p-swarm-derive = { version = "=0.35.1", path = "swarm-derive" } # `libp2p-swarm-derive` may not be compatible with different `libp2p-swarm` non-breaking releases. E.g. `libp2p-swarm` might introduce a new enum variant `FromSwarm` (which is `#[non-exhaustive]`) in a non-breaking release. Older versions of `libp2p-swarm-derive` would not forward this enum variant within the `NetworkBehaviour` hierarchy. Thus the version pinning is required.
107107
libp2p-swarm-test = { version = "0.5.0", path = "swarm-test" }

examples/stream/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ release = false
1212
anyhow = "1"
1313
futures = { workspace = true }
1414
libp2p = { path = "../../libp2p", features = [ "tokio", "quic"] }
15-
libp2p-stream = { path = "../../protocols/stream", version = "0.3.0-alpha" }
15+
libp2p-stream = { path = "../../protocols/stream", version = "0.3.0-alpha.1" }
1616
rand = "0.8"
1717
tokio = { workspace = true, features = ["full"] }
1818
tracing = { workspace = true }

protocols/stream/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 0.3.0-alpha.1
2+
3+
- Garbage-collect deregistered streams when accepting new streams.
4+
See [PR 5999](https://github.com/libp2p/rust-libp2p/pull/5999).
5+
6+
17
## 0.3.0-alpha
28

39
- Deprecate `void` crate.

protocols/stream/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "libp2p-stream"
3-
version = "0.3.0-alpha"
3+
version = "0.3.0-alpha.1"
44
edition.workspace = true
55
rust-version.workspace = true
66
description = "Generic stream protocols for libp2p"

protocols/stream/src/shared.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ impl Shared {
5353
&mut self,
5454
protocol: StreamProtocol,
5555
) -> Result<IncomingStreams, AlreadyRegistered> {
56+
self.supported_inbound_protocols
57+
.retain(|_, sender| !sender.is_closed());
58+
5659
if self.supported_inbound_protocols.contains_key(&protocol) {
5760
return Err(AlreadyRegistered);
5861
}

0 commit comments

Comments
 (0)