Skip to content

Commit 9584709

Browse files
committed
fix: assure we flush before turning a writer into a reader. (#1061)
Otherwise it might be that the write-end still isn't flushed, so the receiver didn't get the message it's waiting on, which wouild cause us to deadlock while waiting for a response from the remote.
1 parent 4e48558 commit 9584709

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

gix-transport/src/client/async_io/request.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ impl<'a> RequestWriter<'a> {
8383
///
8484
/// Doing so will also write the message type this instance was initialized with.
8585
pub async fn into_read(mut self) -> std::io::Result<Box<dyn ExtendedBufRead + Unpin + 'a>> {
86+
use futures_lite::AsyncWriteExt;
8687
self.write_message(self.on_into_read).await?;
88+
self.writer.inner_mut().flush().await?;
8789
Ok(self.reader)
8890
}
8991

gix-transport/src/client/blocking_io/request.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::io;
2+
use std::io::Write;
23

34
use crate::client::{ExtendedBufRead, MessageKind, WriteMode};
45

@@ -60,6 +61,7 @@ impl<'a> RequestWriter<'a> {
6061
/// Doing so will also write the message type this instance was initialized with.
6162
pub fn into_read(mut self) -> std::io::Result<Box<dyn ExtendedBufRead + Unpin + 'a>> {
6263
self.write_message(self.on_into_read)?;
64+
self.writer.inner_mut().flush()?;
6365
Ok(self.reader)
6466
}
6567

0 commit comments

Comments
 (0)