propagate closing in CopyFlush

This commit is contained in:
th4s
2025-12-16 12:17:12 +01:00
parent 30d82e6cb1
commit fbe7b29fcd
2 changed files with 13 additions and 5 deletions

View File

@@ -448,7 +448,6 @@ impl InnerState {
#[instrument(parent = &self.span, level = "debug", skip_all, err)]
async fn server_close(mut self: Box<Self>) -> Result<Box<Self>, ProverError> {
debug!("attempting to close connection serverside");
self.tls.process_new_packets().await?;
self.tls.server_closed().await?;
debug!("closed connection serverside");

View File

@@ -58,7 +58,8 @@ pin_project_lite::pin_project! {
reader: R,
#[pin]
writer: W,
buf: Vec<u8>
buf: Vec<u8>,
closed: bool
}
}
@@ -72,6 +73,7 @@ where
reader,
writer,
buf: Vec::with_capacity(BUF_CAP),
closed: false,
}
}
}
@@ -91,10 +93,14 @@ where
let mut tmp_buf = [0_u8; BUF_CAP];
loop {
if let Poll::Ready(read) = reader.as_mut().poll_read(cx, &mut tmp_buf)?
&& read > 0
if !*this.closed
&& let Poll::Ready(read) = reader.as_mut().poll_read(cx, &mut tmp_buf)?
{
this.buf.extend(&tmp_buf[..read]);
if read > 0 {
this.buf.extend(&tmp_buf[..read]);
} else {
*this.closed = true;
}
}
if this.buf.len() > 0
@@ -102,6 +108,9 @@ where
&& write > 0
{
this.buf.drain(..write);
} else if *this.closed {
let output = writer.as_mut().poll_close(cx)?;
return output.map(|_| Ok(()));
} else {
return Poll::Pending;
}