Skip to content

Commit 3a6642e

Browse files
seanmonstarAaronDewes
authored andcommitted
fix: re-enable verbose connection read logs (seanmonstar#2454)
1 parent 051cd41 commit 3a6642e

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/connect.rs

+13-6
Original file line numberDiff line numberDiff line change
@@ -838,14 +838,21 @@ mod verbose {
838838
fn poll_read(
839839
mut self: Pin<&mut Self>,
840840
cx: &mut Context,
841-
buf: ReadBufCursor<'_>,
841+
mut buf: ReadBufCursor<'_>,
842842
) -> Poll<std::io::Result<()>> {
843-
match Pin::new(&mut self.inner).poll_read(cx, buf) {
843+
// TODO: This _does_ forget the `init` len, so it could result in
844+
// re-initializing twice. Needs upstream support, perhaps.
845+
// SAFETY: Passing to a ReadBuf will never de-initialize any bytes.
846+
let mut vbuf = hyper::rt::ReadBuf::uninit(unsafe { buf.as_mut() });
847+
match Pin::new(&mut self.inner).poll_read(cx, vbuf.unfilled()) {
844848
Poll::Ready(Ok(())) => {
845-
/*
846-
log::trace!("{:08x} read: {:?}", self.id, Escape(buf.filled()));
847-
*/
848-
log::trace!("TODO: verbose poll_read");
849+
log::trace!("{:08x} read: {:?}", self.id, Escape(vbuf.filled()));
850+
let len = vbuf.filled().len();
851+
// SAFETY: The two cursors were for the same buffer. What was
852+
// filled in one is safe in the other.
853+
unsafe {
854+
buf.advance(len);
855+
}
849856
Poll::Ready(Ok(()))
850857
}
851858
Poll::Ready(Err(e)) => Poll::Ready(Err(e)),

0 commit comments

Comments
 (0)