Skip to content

Commit

Permalink
fix buffer upper bound.
Browse files Browse the repository at this point in the history
  • Loading branch information
fakeshadow committed Apr 18, 2024
1 parent 6d7b140 commit 5197ecc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions postgres/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ async fn listen_task(conn: Incoming, addr: SocketAddr) -> Result<(), Error> {
loop {
match rx.read(&mut buf).select(upstream.ready(Interest::READABLE)).await {
SelectOutput::A(Ok(Some(len))) => {
let mut written = 0;
while written != len {
match upstream.write(&buf[written..]) {
let mut off = 0;
while off != len {
match upstream.write(&buf[off..len]) {
Ok(0) => return Ok(()),
Ok(n) => written += n,
Ok(n) => off += n,
Err(e) if e.kind() == io::ErrorKind::WouldBlock => {
upstream.ready(Interest::WRITABLE).await?;
}
Expand Down

0 comments on commit 5197ecc

Please sign in to comment.