Skip to content

Commit

Permalink
fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
tahmid-23 committed May 22, 2024
1 parent d152300 commit 2565c62
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ exclude = ["/.github", "/examples", "/scripts"]
[dependencies]
tokio = "1.0"
rustls = { version = "0.23.5", default-features = false, features = ["std"] }
pin-project-lite = "0.2.14"
pki-types = { package = "rustls-pki-types", version = "1" }

[features]
Expand All @@ -35,3 +34,4 @@ futures-util = "0.3.1"
lazy_static = "1.1"
webpki-roots = "0.26"
rustls-pemfile = "2"
pin-project-lite = "0.2.14"
15 changes: 9 additions & 6 deletions src/server.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::io;
use std::io::Read;
#[cfg(unix)]
use std::os::unix::io::{AsRawFd, RawFd};
#[cfg(windows)]
Expand Down Expand Up @@ -107,6 +106,8 @@ where
cx: &mut Context<'_>,
buf: &mut ReadBuf<'_>,
) -> Poll<io::Result<()>> {
use std::io::Read;

let this = self.get_mut();
let mut stream =
Stream::new(&mut this.io, &mut this.session).set_eof(!this.state.readable());
Expand All @@ -132,19 +133,21 @@ where

if let Some(mut early_data) = stream.session.early_data() {
match early_data.read(buf.initialize_unfilled()) {
Ok(n) => if n > 0 {
buf.advance(n);
return Poll::Ready(Ok(()));
Ok(n) => {
if n > 0 {
buf.advance(n);
return Poll::Ready(Ok(()));
}
}
Err(err) => return Poll::Ready(Err(err))
Err(err) => return Poll::Ready(Err(err)),
}
}

if stream.session.is_handshaking() {
return Poll::Pending;
}

return Poll::Ready(Ok(()));
Poll::Ready(Ok(()))
}
TlsState::ReadShutdown | TlsState::FullyShutdown => Poll::Ready(Ok(())),
s => unreachable!("server TLS can not hit this state: {:?}", s),
Expand Down
11 changes: 8 additions & 3 deletions tests/early-data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,13 @@ pin_project! {

impl<IO> AsyncRead for TlsStreamEarlyWrapper<IO>
where
IO: AsyncRead + AsyncWrite + Unpin {
fn poll_read(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut ReadBuf<'_>) -> Poll<io::Result<()>> {
IO: AsyncRead + AsyncWrite + Unpin,
{
fn poll_read(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut ReadBuf<'_>,
) -> Poll<io::Result<()>> {
return self.project().inner.poll_read_early_data(cx, buf);
}
}
Expand Down Expand Up @@ -103,7 +108,7 @@ async fn test_0rtt_impl(vectored: bool) -> io::Result<()> {
let stream = acceptor.accept(&mut sock).await.unwrap();

let mut buf = Vec::new();
let mut stream_wrapper = TlsStreamEarlyWrapper{ inner: stream };
let mut stream_wrapper = TlsStreamEarlyWrapper { inner: stream };
stream_wrapper.read_to_end(&mut buf).await.unwrap();
let mut stream = stream_wrapper.inner;
stream.write_all(b"EARLY:").await.unwrap();
Expand Down

0 comments on commit 2565c62

Please sign in to comment.