Skip to content

httpd: add async accept#29

Merged
keszybz merged 2 commits intosystemd:mainfrom
mvo5:non-blocking-accept
Apr 15, 2026
Merged

httpd: add async accept#29
keszybz merged 2 commits intosystemd:mainfrom
mvo5:non-blocking-accept

Conversation

@mvo5
Copy link
Copy Markdown
Contributor

@mvo5 mvo5 commented Mar 27, 2026

Our TlsListener::new() code was syncronous - so slow clients could stall/block the server. This commit adds a new AsyncTlsListener that avoids this problem by using tokio::spawn().

This is very similar to the tls-listener crate but that does not implement the axum serve::Listener trait so using it is a bit cumbersome and its not much code that we add here (its a bit of a tradeoff, happy to hear opinions).

Copy link
Copy Markdown
Member

@keszybz keszybz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dunno, if this compiles, that it's probably OK. But with this level of abstraction I'm not sure if I grok all the implications.

{
fn new(mut inner: L, acceptor: openssl::ssl::SslAcceptor) -> std::io::Result<Self> {
let local_addr = inner.local_addr()?;
let (tx, rx) = tokio::sync::mpsc::channel(256);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this could be defined as a constant somewhere at the top of the file…

mvo5 added 2 commits April 15, 2026 11:26
The tls code is now logging the connectins in `connect_info()`
just like PlainListener and the coming VsockListener.

This way the code becomes more symmetrical.
Our TlsListener::new() code was syncronous - so slow clients
could stall/block the server. This commit adds a new AsyncTlsListener
that avoids this problem by using tokio::spawn() and a `mpsc`
(multi-producer, single-consume) channel.

This is very similar to the `tls-listener` crate but that does
not implement the axum `serve::Listener` trait so using it is
a bit cumbersome and its not much code that we add here.
@keszybz keszybz force-pushed the non-blocking-accept branch from d938c07 to c409b48 Compare April 15, 2026 09:26
@keszybz keszybz merged commit 2bd0b50 into systemd:main Apr 15, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants