Skip to content

Commit 9915cf9

Browse files
committed
fix: concurrent
1 parent 4360510 commit 9915cf9

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/api.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,14 @@ fn stream(
8080
) -> impl TryStream<Ok = impl AsyncRead + AsyncWrite + Send + Unpin + 'static, Error = Error> + Send
8181
{
8282
let acceptor = Acceptor::new(pool);
83-
let acceptor_stream = repeat(acceptor).then(|a| async move { a.load_cert().await });
8483

8584
listener
86-
.zip(acceptor_stream)
87-
.then(|item| async move {
88-
match item {
89-
(Ok(stream), Ok(acceptor)) => Ok(acceptor.accept(stream).await?),
90-
(Err(e), _) => Err(e.into()),
91-
(_, Err(e)) => Err(e),
92-
}
85+
.zip(repeat(acceptor))
86+
.map(|(stream, acceptor)| async move {
87+
let acceptor = acceptor.load_cert().await?;
88+
Ok(acceptor.accept(stream?).await?)
9389
})
90+
.buffer_unordered(100)
9491
.inspect_err(|err| log::error!("Stream error: {}", err))
9592
.filter(|stream| futures_util::future::ready(stream.is_ok()))
9693
}

0 commit comments

Comments
 (0)