buffer up to a limit

This commit is contained in:
Lev Kokotov
2022-02-05 14:38:41 -08:00
parent e13795d762
commit 7d895b9e37

View File

@@ -247,9 +247,21 @@ impl Server {
}
};
self.data_available = false;
break;
}
'D' => {
self.data_available = true;
// Don't flush yet, the more we buffer, the faster this goes.
// Up to a limit of course.
if self.buffer.len() >= 8196 {
break;
}
}
// CopyInResponse: copy is starting from client to server
'G' => break,
@@ -340,7 +352,12 @@ impl Server {
msg.put_slice(&query[..]);
self.send(msg).await?;
let _ = self.recv().await?;
loop {
let _ = self.recv().await?;
if !self.data_available {
break;
}
}
Ok(())
}