chore: Truncate pending read_buf when empty to release memory

This commit is contained in:
Σrebe - Romain GERARD 2024-09-30 09:13:19 +02:00
parent c2d140aaba
commit b7901bc38c
No known key found for this signature in database
GPG key ID: 7A42B4B97E0332F4

View file

@ -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(()));
}