Skip to content

Commit

Permalink
Revert "Drain stdin on attach"
Browse files Browse the repository at this point in the history
Signed-off-by: Sascha Grunert <[email protected]>
  • Loading branch information
saschagrunert committed Jan 12, 2023
1 parent 6988e92 commit d51f08e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions conmon-rs/server/src/attach.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ impl SharedContainerAttach {
.context("receive attach message")
}

/// Try to read from all attach endpoints standard input and return the first result.
pub fn try_read(&mut self) -> Result<Vec<u8>> {
self.read_half_rx
.try_recv()
.context("try to receive attach message")
}

/// Write a buffer to all attach endpoints.
pub async fn write(&mut self, m: Message) -> Result<()> {
if self.write_half_tx.receiver_count() > 0 {
Expand Down
6 changes: 3 additions & 3 deletions conmon-rs/server/src/container_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,11 @@ impl ContainerIO {
}
}
_ = token.cancelled() => {
debug!("Token cancelled, draining stdin");
if let Ok(data) = attach.read().await {
// Closing immediately may race with outstanding data on stdin for short lived
// containers. This means we try to read once again.
if let Ok(data) = attach.try_read() {
Self::handle_stdin_data(&data, &mut writer).await?;
}

return Ok(());
}
}
Expand Down

0 comments on commit d51f08e

Please sign in to comment.