-
Notifications
You must be signed in to change notification settings - Fork 63
chore: write/read in progress for tls socket #429
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
Conversation
Signed-off-by: kostas <[email protected]>
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #429 +/- ##
==========================================
+ Coverage 77.60% 79.26% +1.65%
==========================================
Files 103 112 +9
Lines 7824 10282 +2458
==========================================
+ Hits 6072 8150 +2078
- Misses 1752 2132 +380 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements handling for WRITE_IN_PROGRESS and READ_IN_PROGRESS states in TLS socket operations to prevent deadlocks when multiple async operations are attempted concurrently. When an I/O operation is in progress and cannot be preempted, the implementation now queues pending operations using a blocked_async_req_ member variable.
- Added blocking mechanism using
blocked_async_req_to handle concurrent read/write operations - Implemented
RunBlocked()method to resume pending operations when current operations complete - Added comprehensive test coverage for partial read/write scenarios and renegotiation
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| util/tls/tls_socket.h | Added blocked_async_req_ member and RunBlocked() method declaration |
| util/tls/tls_socket.cc | Implemented blocking logic and RunBlocked() method to handle concurrent operations |
| util/tls/tls_socket_test.cc | Added test classes for partial read/write operations and TLS renegotiation scenarios |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
util/tls/tls_socket.cc
Outdated
| auto* blocked = std::exchange(owner_->blocked_async_req_, nullptr); | ||
|
|
||
| if (blocked->should_read_) { | ||
| should_read_ = false; |
Copilot
AI
Aug 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting should_read_ = false on the current request (this) instead of the blocked request appears incorrect. This should likely be blocked->should_read_ = false; to clear the flag on the request that's about to be processed.
| should_read_ = false; | |
| blocked->should_read_ = false; |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to double check this but it suffices to set it to false for the current operation. Will get back to this.
| return; | ||
| } | ||
|
|
||
| if (blocked->role_ == Role::WRITER) { |
Copilot
AI
Aug 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic assumes that if the blocked request is not a writer, it must be a reader, but there's no explicit check for Role::READER. Consider adding an explicit check or an else-if clause to make the intent clearer and handle unexpected role values.
Copilot uses AI. Check for mistakes.
| return; | ||
| } | ||
| auto current = std::move(owner_->async_read_req_); | ||
| owner_->AsyncReadSome(current->vec_, current->len_, std::move(current->caller_completion_cb_)); |
Copilot
AI
Aug 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the write case, moving async_read_req_ before calling AsyncReadSome could be problematic since AsyncReadSome likely expects async_read_req_ to be null to create a new request.
| owner_->AsyncReadSome(current->vec_, current->len_, std::move(current->caller_completion_cb_)); | |
| // Extract data before resetting async_read_req_ | |
| auto* current = owner_->async_read_req_.get(); | |
| auto vec = current->vec_; | |
| auto len = current->len_; | |
| auto cb = std::move(current->caller_completion_cb_); | |
| owner_->async_read_req_.reset(); | |
| owner_->AsyncReadSome(vec, len, std::move(cb)); |
Copilot uses AI. Check for mistakes.
util/tls/tls_socket.h
Outdated
|
|
||
| void AsyncProgressCb(io::Result<size_t> result); | ||
|
|
||
| void RunBlocked(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a comment what this and blocked_async_req_ are?
What is blocked in this context?
Signed-off-by: Kostas Kyrimis <[email protected]>
Handle
WRITE_IN_PROGRESSandREAD_IN_PROGRESS. Specifically, when an operation is is progress we can no longer preempt because the context the IO operation is running does not allow preemption (it's not an actual fiber but a function). To solve this, we add apendingmember variable which we set when a read or a write is in progress. When the IO operation we got blocked completes it will also resume/handle the pending one.