Skip to content

Commit a04fa88

Browse files
Never busywait
1 parent ddf4ebc commit a04fa88

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/ktls_stream.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,15 @@ where
104104
let r = match r {
105105
Ok(r) => r,
106106
Err(nix::errno::Errno::EAGAIN) => {
107-
// this time don't `wake_by_ref` on purpose, but try to to clear readiness
108-
tracing::trace!("KtlsStream::poll_read, got EAGAIN");
109-
match this.inner.poll_read_ready(cx) {
110-
task::Poll::Ready(s) => {
111-
tracing::trace!("KtlsStream::poll_read, got Ready, {s:#?}")
112-
}
113-
task::Poll::Pending => {
114-
tracing::trace!("KtlsStream::poll_read, got Pending")
107+
// this time don't `wake_by_ref` on purpose, but clear readiness by calling
108+
// poll_read, knowing it'll fail
109+
tracing::trace!("KtlsStream::poll_read, recvmsg gave us EAGAIN/EWOULDBLOCK");
110+
match this.inner.poll_read(cx, buf) {
111+
task::Poll::Ready(_) => {
112+
unreachable!("one of ktls's core assumptions about async I/O didn't hold")
115113
}
114+
task::Poll::Pending => return task::Poll::Pending,
116115
}
117-
cx.waker().wake_by_ref();
118-
return task::Poll::Pending;
119116
}
120117
Err(e) => {
121118
tracing::trace!(?e, "recvmsg failed");

0 commit comments

Comments
 (0)