Skip to content

feat: add accept method (supersedes #292) - #314

Open
KarstenB wants to merge 1 commit into
containerd:masterfrom
KarstenB:feat/add_accept_method
Open

KarstenB wants to merge 1 commit into
containerd:masterfrom
KarstenB:feat/add_accept_method

Conversation

@KarstenB

Copy link
Copy Markdown

Add accept method for better error handling and ergononics when only one connection is expected. Fixes #293

I didn't want to force push on a branch that is already used externally, but this branch removes the &mut self in favor of a &self.

@KarstenB KarstenB mentioned this pull request May 12, 2026
Comment thread src/asynchronous/server.rs Outdated
Comment thread src/asynchronous/server.rs Outdated

@Tim-Zhang Tim-Zhang left a comment

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.

These two issues prevent the new API from providing the advertised error handling and task control. Non-blocking: since the socket is already connected, serve_connection would describe the operation more accurately than accept. Also, spawn_connection_handler has no await point of its own, so it can be a regular function and its call-site .await can be removed.

Comment thread src/asynchronous/server.rs Outdated
streams: Arc::default(),
shutdown_waiter: self.shutdown.subscribe(),
};
Connection::new(conn, delegate).run().await

@Tim-Zhang Tim-Zhang Aug 6, 2026 •

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.

Propagate connection failures from accept

Connection::run() handles GenMessageError::InternalError by disconnecting and breaking, then unconditionally returns Ok(()). Read and decoding failures therefore remain hidden, defeating this API’s stated error-handling purpose. Preserve the termination error through cleanup and return it here; writer failures should also be surfaced.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This is now addressed, I didn't quite like to have mut variable just to get the error out of the loop, the break with return type is a bit exotic syntax. Let me know what your preference here is. I didn't want to duplicate the cleanup.

Comment thread src/asynchronous/server.rs Outdated
@KarstenB
KarstenB force-pushed the feat/add_accept_method branch 2 times, most recently from bdcba72 to 62ced0a Compare September 23, 2026 12:50
Add a serve_connection method to serve a single already-connected socket,
for better error handling and ergonomics when only one connection is
expected. The returned future is Send + 'static so it can be spawned, and
connection read/write failures are propagated as the crate Result.
Fixes containerd#293

Signed-off-by: Karsten Becker <567973+KarstenB@users.noreply.github.com>
Co-authored-by: Jorge Prendes <jorge.prendes@gmail.com>
@KarstenB
KarstenB force-pushed the feat/add_accept_method branch from 62ced0a to 7578832 Compare September 23, 2026 13:00
@KarstenB
KarstenB requested a review from Tim-Zhang September 23, 2026 14:07
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.

Add single connection support to Server

3 participants