mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-09 06:22:57 +00:00
Avoid short writes if a buffer is full.
write_buf() tries to write as much as it can in one go, and can return without writing the whole buffer. We need to use write_all() instead.
This commit is contained in:
@@ -317,7 +317,7 @@ impl Connection {
|
||||
.await?;
|
||||
|
||||
self.stream.write_i16(1).await?;
|
||||
self.stream.write_buf(&mut b).await?;
|
||||
self.stream.write_all(&mut b).await?;
|
||||
self.stream.write_i32(0).await?; /* table oid */
|
||||
self.stream.write_i16(0).await?; /* attnum */
|
||||
self.stream.write_i32(25).await?; /* TEXTOID */
|
||||
@@ -336,7 +336,7 @@ impl Connection {
|
||||
|
||||
self.stream.write_i16(1).await?;
|
||||
self.stream.write_i32(b.len() as i32).await?;
|
||||
self.stream.write_buf(&mut b).await?;
|
||||
self.stream.write_all(&mut b).await?;
|
||||
}
|
||||
|
||||
BeMessage::ControlFile => {
|
||||
@@ -348,7 +348,7 @@ impl Connection {
|
||||
|
||||
self.stream.write_i16(1).await?;
|
||||
self.stream.write_i32(b.len() as i32).await?;
|
||||
self.stream.write_buf(&mut b).await?;
|
||||
self.stream.write_all(&mut b).await?;
|
||||
}
|
||||
|
||||
BeMessage::CommandComplete => {
|
||||
@@ -356,7 +356,7 @@ impl Connection {
|
||||
|
||||
self.stream.write_u8(b'C').await?;
|
||||
self.stream.write_i32(4 + b.len() as i32).await?;
|
||||
self.stream.write_buf(&mut b).await?;
|
||||
self.stream.write_all(&mut b).await?;
|
||||
}
|
||||
|
||||
BeMessage::ZenithStatusResponse(resp) => {
|
||||
@@ -383,7 +383,7 @@ impl Connection {
|
||||
self.stream.write_u8(102).await?; /* tag from pagestore_client.h */
|
||||
self.stream.write_u8(resp.ok as u8).await?;
|
||||
self.stream.write_u32(resp.n_blocks).await?;
|
||||
self.stream.write_buf(&mut resp.page.clone()).await?;
|
||||
self.stream.write_all(&mut resp.page.clone()).await?;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -404,7 +404,7 @@ impl Connection {
|
||||
match m.kind {
|
||||
StartupRequestCode::NegotiateGss | StartupRequestCode::NegotiateSsl => {
|
||||
let mut b = Bytes::from("N");
|
||||
self.stream.write_buf(&mut b).await?;
|
||||
self.stream.write_all(&mut b).await?;
|
||||
self.stream.flush().await?;
|
||||
}
|
||||
StartupRequestCode::Normal => {
|
||||
|
||||
Reference in New Issue
Block a user