Skip to content

feat: copy_bidirectional_with_timeout added#1

Open
dilitvinov wants to merge 2 commits into
hanyu-dev:masterfrom
dilitvinov:add_copy_bidirectional_with_timeout
Open

feat: copy_bidirectional_with_timeout added#1
dilitvinov wants to merge 2 commits into
hanyu-dev:masterfrom
dilitvinov:add_copy_bidirectional_with_timeout

Conversation

@dilitvinov
Copy link
Copy Markdown

Add read-idle drain timeout to copy_bidirectional

Problem

poll_splice_drain waits for the source to become readable with no upper bound. If the remote peer stops sending data without closing the connection, the task parks indefinitely — no CPU is wasted, but the connection is never cleaned up.

Solution

Introduce an optional read-idle timeout for the drain phase.

API

copy_bidirectional_with_timeout(&mut sl, &mut sr, Duration::from_secs(30)).await?;

No timeout is applied by default — existing behaviour is unchanged, no breaking changes.

Any suggestions are welcomed!

@dilitvinov
Copy link
Copy Markdown
Author

@cxw620 please, have a look 🙏

@cxw620
Copy link
Copy Markdown
Contributor

cxw620 commented May 7, 2026

I will test it locally when I have free time on this weekend. CI is broken because tracing-subscriber and its dependency time does not follow the MSRV they claim, please don't mind. Thank you for your work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants