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

Added SSL read/write queues. #952

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

sonnin
Copy link

@sonnin sonnin commented Aug 26, 2019

Comments in the code states below:
// only one read operation is allowed now
// later it will be possible to make a queue

Somehow our usage of ACE 6.1.7 hits this limitation in some situations. Resulting in read/write errors.

Adding read/write queues resolves this limitation.

Summary by CodeRabbit

  • Refactor

    • Enhanced asynchronous stream handling to support multiple, concurrent read and write operations. This improvement leads to better performance, responsiveness, and reliability during secure communications and data transfers.
  • Chores

    • Optimized internal memory management to ensure efficient cleanup of asynchronous tasks, contributing to improved system stability and a more robust operational experience for users.

SSL connection was unstable on high load
@jwillemsen jwillemsen added the needs review Needs to be reviewed label May 7, 2020
@jwillemsen
Copy link
Member

Some fuzz errors

Running NULL usage check
Error: ./ACE/ace/SSL/SSL_Asynch_Stream.cpp:342: NULL found
Error: ./ACE/ace/SSL/SSL_Asynch_Stream.cpp:382: NULL found

@jwillemsen
Copy link
Member

Do you have an extension or new ACE unit test to validate this new code?

@sonnin
Copy link
Author

sonnin commented May 18, 2020

Do you have an extension or new ACE unit test to validate this new code?

No.

The existing test should continue to work. But will only test with one message in the queue. Hence the FIFO logic is not validated by test cases.

@jwillemsen
Copy link
Member

Can you extend the exiting test to also test the FIFO logic?

Copy link
Contributor

coderabbitai bot commented Feb 1, 2025

Walkthrough

The changes update asynchronous stream handling by replacing single-pointer mechanisms with queues for managing multiple asynchronous read and write results. In both implementation and declarations, pointers have been substituted with container types (queue/list) to store multiple results. The constructor, destructor, read/write methods, and notification functions have been modified to support queue-based management and proper memory cleanup. These modifications improve concurrent operation handling and lifecycle management of asynchronous operations.

Changes

File Path Change Summary
ACE/ace/SSL/.../SSL_Asynch_Stream.cpp Replaced single read/write result pointers with queues; updated constructor, destructor (looping through the queues), read/write methods to enqueue new result objects, and notify methods to dequeue and dispatch results.
ACE/ace/SSL/.../SSL_Asynch_Stream.h Changed asynchronous result pointers to list containers for read/write results and adjusted access specifiers from protected to private.

Sequence Diagram(s)

sequenceDiagram
    participant U as User Handler
    participant S as SSL_Asynch_Stream
    participant RQ as Read Result Queue

    U->>S: Call read()
    S->>RQ: Enqueue new Read Result
    Note over S,RQ: Asynchronous read operation in progress
    S->>RQ: On completion, dequeue result
    RQ--)S: Return read result
    S->>U: notify_read(result)
Loading
sequenceDiagram
    participant U as User Handler
    participant S as SSL_Asynch_Stream
    participant WQ as Write Result Queue

    U->>S: Call write(data)
    S->>WQ: Enqueue new Write Result
    Note over S,WQ: Asynchronous write operation in progress
    S->>WQ: On completion, dequeue result
    WQ--)S: Return write result
    S->>U: notify_write(result)
Loading

Poem

I'm a hopping little rabbit with code so sweet,
Watching queues replace pointers in each heartbeat.
Reads and writes now dance in orderly rows,
Popping out results like fresh springtime shows.
Cheers to new flows and memory managed neat! 🐇🌸

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (4)
ACE/ace/SSL/SSL_Asynch_Stream.cpp (2)

340-354: Prefer using smart pointers for Result objects.
Creating raw pointers and manually deleting them in multiple places can be error-prone. Using smart pointers (e.g., std::unique_ptr) could reduce memory management risks and simplify the code.

-ACE_SSL_Asynch_Read_Stream_Result* result = 0;
-ACE_NEW_RETURN (result,
-                ACE_SSL_Asynch_Read_Stream_Result (
-                  ...
-                ),
-                -1);
-ext_read_result_queue_.push_back(result);
+auto result = std::make_unique<ACE_SSL_Asynch_Read_Stream_Result>(
+  *this->ext_handler_,
+  this->handle (),
+  message_block,
+  bytes_to_read,
+  act,
+  this->proactor_->get_handle(),
+  priority,
+  signal_number
+);
// ...
+ext_read_result_queue_.push_back(result.release());

380-395: Unify read/write creation logic.
The logic creating and queuing write results mirrors the read results. Consider extracting common code into a helper function for consistency and reduced duplication.

ACE/ace/SSL/SSL_Asynch_Stream.h (2)

16-16: Confirm container choice for better performance.
Using std::list for frequent front pop and back push is acceptable, but std::deque may offer better cache locality. Evaluate if switching to std::deque would help.


383-389: Raw pointer storage in container.
Storing raw pointers in a standard container requires diligent manual memory handling. If feasible, consider a container of smart pointers (e.g., std::unique_ptr) to reduce the chance of leaks or double frees.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 13acc82 and 6b26c88.

📒 Files selected for processing (2)
  • ACE/ace/SSL/SSL_Asynch_Stream.cpp (11 hunks)
  • ACE/ace/SSL/SSL_Asynch_Stream.h (2 hunks)
🔇 Additional comments (7)
ACE/ace/SSL/SSL_Asynch_Stream.cpp (7)

152-159: Consider verifying no active requests before destruction.
Although this destructor attempts to delete all queued results, please ensure all in-flight read/write operations have completed or been canceled before these pointers are destroyed. Otherwise, there's a risk of dangling pointers if completions arrive after destruction.


566-566: Conditional check for an empty read queue looks correct.
No issues here; the code properly returns early if no read operations are queued.


577-579: Verify front() usage under concurrency.
Accessing front() is valid only if the queue remains non-empty. While the preceding check ensures emptiness is handled, consider re-checking if concurrency might invalidate that assumption.


628-628: Early return for empty write queue is clear.
This condition matches the read queue approach and maintains consistency.


639-640: Front-access usage mirrors do_SSL_read.
Just like in do_SSL_read(), the code retrieves the front item for processing. Implementation looks consistent with the empty-check.


730-741: Confirm multiple queued reads are fully processed.
This notification logic handles completion for the front of the queue, popping it on success. Verify that subsequent queued reads are also eventually processed—especially under partial reads or repeated SSL states.


760-772: Write completion notification is consistent.
This notification pattern aligns with the read side. The approach appears sound for single-queue usage per completion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs review Needs to be reviewed
Development

Successfully merging this pull request may close these issues.

2 participants