From 170a7e25543d34a8055fdf096a1815a82776873d Mon Sep 17 00:00:00 2001 From: Diego Date: Tue, 11 Jun 2024 11:34:42 +0200 Subject: [PATCH 1/2] make the test flaky and sometimes cause a deadlock --- test-harness/tests/poll_api.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test-harness/tests/poll_api.rs b/test-harness/tests/poll_api.rs index 7f23a03..eb674ba 100644 --- a/test-harness/tests/poll_api.rs +++ b/test-harness/tests/poll_api.rs @@ -210,7 +210,7 @@ fn write_deadlock() { // We make the message to transmit large enough s.t. the "server" // is forced to start writing (i.e. echoing) the bytes before // having read the entire payload. - let msg = vec![1u8; 1024 * 1024]; + let msg = vec![1u8; 100024 * 100024]; // We choose a "connection capacity" that is artificially below // the size of a receive window. If it were equal or greater, @@ -219,7 +219,7 @@ fn write_deadlock() { // fact that the sum of receive windows of all open streams can easily // be larger than the send capacity of the connection at any point in time. // Using such a low capacity here therefore yields a more reproducible test. - let capacity = 1024; + let capacity = 10024; // Create a bounded channel representing the underlying "connection". // Each endpoint gets a name and a bounded capacity for its outbound From 4936da84b12a695fb49160c50390e3e97a95e5e6 Mon Sep 17 00:00:00 2001 From: Diego Date: Tue, 11 Jun 2024 11:38:08 +0200 Subject: [PATCH 2/2] try to read a pending frame before sending a ping --- yamux/src/connection.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/yamux/src/connection.rs b/yamux/src/connection.rs index 24c53c7..e6f7821 100644 --- a/yamux/src/connection.rs +++ b/yamux/src/connection.rs @@ -391,14 +391,6 @@ impl Active { fn poll(&mut self, cx: &mut Context<'_>) -> Poll> { loop { if self.socket.poll_ready_unpin(cx).is_ready() { - // Note `next_ping` does not register a waker and thus if not called regularly (idle - // connection) no ping is sent. This is deliberate as an idle connection does not - // need RTT measurements to increase its stream receive window. - if let Some(frame) = self.rtt.next_ping() { - self.socket.start_send_unpin(frame.into())?; - continue; - } - // Privilege pending `Pong` and `GoAway` `Frame`s // over `Frame`s from the receivers. if let Some(frame) = self @@ -409,6 +401,14 @@ impl Active { self.socket.start_send_unpin(frame)?; continue; } + + // Note `next_ping` does not register a waker and thus if not called regularly (idle + // connection) no ping is sent. This is deliberate as an idle connection does not + // need RTT measurements to increase its stream receive window. + if let Some(frame) = self.rtt.next_ping() { + self.socket.start_send_unpin(frame.into())?; + continue; + } } match self.socket.poll_flush_unpin(cx)? {