Skip to content

Commit d99e90d

Browse files
authored
fix: re-enable verbose connection read logs (#2454)
1 parent aba01ff commit d99e90d

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
@@ -1140,14 +1140,21 @@ mod verbose {
11401140
fn poll_read(
11411141
mut self: Pin<&mut Self>,
11421142
cx: &mut Context,
1143-
buf: ReadBufCursor<'_>,
1143+
mut buf: ReadBufCursor<'_>,
11441144
) -> Poll<std::io::Result<()>> {
1145-
match Pin::new(&mut self.inner).poll_read(cx, buf) {
1145+
// TODO: This _does_ forget the `init` len, so it could result in
1146+
// re-initializing twice. Needs upstream support, perhaps.
1147+
// SAFETY: Passing to a ReadBuf will never de-initialize any bytes.
1148+
let mut vbuf = hyper::rt::ReadBuf::uninit(unsafe { buf.as_mut() });
1149+
match Pin::new(&mut self.inner).poll_read(cx, vbuf.unfilled()) {
11461150
Poll::Ready(Ok(())) => {
1147-
/*
1148-
log::trace!("{:08x} read: {:?}", self.id, Escape(buf.filled()));
1149-
*/
1150-
log::trace!("TODO: verbose poll_read");
1151+
log::trace!("{:08x} read: {:?}", self.id, Escape(vbuf.filled()));
1152+
let len = vbuf.filled().len();
1153+
// SAFETY: The two cursors were for the same buffer. What was
1154+
// filled in one is safe in the other.
1155+
unsafe {
1156+
buf.advance(len);
1157+
}
11511158
Poll::Ready(Ok(()))
11521159
}
11531160
Poll::Ready(Err(e)) => Poll::Ready(Err(e)),

0 commit comments

Comments
 (0)