Conversation
Tim-Zhang
left a comment
There was a problem hiding this comment.
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.
| streams: Arc::default(), | ||
| shutdown_waiter: self.shutdown.subscribe(), | ||
| }; | ||
| Connection::new(conn, delegate).run().await |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
bdcba72 to
62ced0a
Compare
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>
62ced0a to
7578832
Compare
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 selfin favor of a&self.