chore: Truncate pending read_buf when empty to release memory
This commit is contained in:
parent
c2d140aaba
commit
b7901bc38c
1 changed files with 3 additions and 0 deletions
|
@ -115,6 +115,9 @@ impl AsyncRead for TransportReadHalf {
|
||||||
let copy_len = cmp::min(read_buf.len(), buf.remaining());
|
let copy_len = cmp::min(read_buf.len(), buf.remaining());
|
||||||
buf.put_slice(&read_buf[..copy_len]);
|
buf.put_slice(&read_buf[..copy_len]);
|
||||||
read_buf.advance(copy_len);
|
read_buf.advance(copy_len);
|
||||||
|
if read_buf.is_empty() {
|
||||||
|
read_buf.clear();
|
||||||
|
}
|
||||||
return Poll::Ready(Ok(()));
|
return Poll::Ready(Ok(()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue