Skip to content

Commit 3da7d91

Browse files
fix(webrtc-utils): read buffer only if empty message
This PR adds a return of `Poll::Ready(Ok(0))` when the `message` vector is empty or not present. This missing return was causing the stream not to finish, then to be dropped, causing the request response protocol to fail over WebRTC. Now that empty or non existent message vectors get returned as `Ok(0)` the stream can be read and request response works now over WebRTC. Pull-Request: libp2p#5439.
1 parent 9dcc172 commit 3da7d91

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
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
@@ -110,7 +110,7 @@ libp2p-tls = { version = "0.4.0", path = "transports/tls" }
110110
libp2p-uds = { version = "0.40.0", path = "transports/uds" }
111111
libp2p-upnp = { version = "0.2.2", path = "protocols/upnp" }
112112
libp2p-webrtc = { version = "0.7.1-alpha", path = "transports/webrtc" }
113-
libp2p-webrtc-utils = { version = "0.2.0", path = "misc/webrtc-utils" }
113+
libp2p-webrtc-utils = { version = "0.2.1", path = "misc/webrtc-utils" }
114114
libp2p-webrtc-websys = { version = "0.3.0-alpha", path = "transports/webrtc-websys" }
115115
libp2p-websocket = { version = "0.43.0", path = "transports/websocket" }
116116
libp2p-websocket-websys = { version = "0.3.2", path = "transports/websocket-websys" }

misc/webrtc-utils/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.2.1
2+
3+
- Fix end of stream handling when buffer is empty or not present.
4+
See [PR 5439](https://github.com/libp2p/rust-libp2p/pull/5439).
5+
16
## 0.2.0
27

38
- Update to latest version of `libp2p-noise`.

misc/webrtc-utils/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ license = "MIT"
77
name = "libp2p-webrtc-utils"
88
repository = "https://github.com/libp2p/rust-libp2p"
99
rust-version = { workspace = true }
10-
version = "0.2.0"
10+
version = "0.2.1"
1111
publish = true
1212

1313
[dependencies]

misc/webrtc-utils/src/stream.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,14 @@ where
146146
}
147147

148148
debug_assert!(read_buffer.is_empty());
149-
if let Some(message) = message {
150-
*read_buffer = message.into();
149+
match message {
150+
Some(msg) if !msg.is_empty() => {
151+
*read_buffer = msg.into();
152+
}
153+
_ => {
154+
tracing::debug!("poll_read buffer is empty, received None");
155+
return Poll::Ready(Ok(0));
156+
}
151157
}
152158
}
153159
None => {

0 commit comments

Comments
 (0)