Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement tls_socket async write/read #361

Open
romange opened this issue Jan 8, 2025 · 0 comments · May be fixed by #376
Open

implement tls_socket async write/read #361

romange opened this issue Jan 8, 2025 · 0 comments · May be fixed by #376
Labels
enhancement New feature or request

Comments

@romange
Copy link
Owner

romange commented Jan 8, 2025

Currently tls_socket routines follow a state machine dictated by tls engine by issuing synchronous I/O operations on the upstream TSP socket.

For AsyncWrite/Read we must reimplement the entire flow in such that we call only AsyncWrite/Read on tcp socket.
In order to keep the state we must introduce a state variable on heap and track the progress of the operation.
We can chain callbacks of the underlying AsyncWrite/Read calls on tcp socket in order to transition from state to state.

For example, EpollSocket::AsyncWriteSome or AsyncWriteState in io.cc also use heap allocates states to keep track of operations.

One thing to remember: we should also handle the state where both read and write tls operations require reading from socket with NEED_READ_AND_MAYBE_WRITE. With synchronous calls we just yield and stall to avoid contention. with asynchronous it won't work. So in that case only the first operation must do this, and another one should subscribe to the first one completion, and continue when reading from socket is done.

@romange romange added the enhancement New feature or request label Jan 8, 2025
@romange romange changed the title implement tls_socket write/read implement tls_socket async write/read Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant