From b7901bc38c2fe36935b3ef2fc9c96176477383fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=A3rebe=20-=20Romain=20GERARD?= Date: Mon, 30 Sep 2024 09:13:19 +0200 Subject: [PATCH] chore: Truncate pending read_buf when empty to release memory --- src/tunnel/client/l4_transport_stream.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tunnel/client/l4_transport_stream.rs b/src/tunnel/client/l4_transport_stream.rs index 879416d..bc1368d 100644 --- a/src/tunnel/client/l4_transport_stream.rs +++ b/src/tunnel/client/l4_transport_stream.rs @@ -115,6 +115,9 @@ impl AsyncRead for TransportReadHalf { let copy_len = cmp::min(read_buf.len(), buf.remaining()); buf.put_slice(&read_buf[..copy_len]); read_buf.advance(copy_len); + if read_buf.is_empty() { + read_buf.clear(); + } return Poll::Ready(Ok(())); }