Skip to content

Release resources used by SSL diagnostic output - #3657

Open
wasphin wants to merge 3 commits into
apache:masterfrom
wasphin:fix-ssl-diagnostic-ownership
Open

wasphin wants to merge 3 commits into
apache:masterfrom
wasphin:fix-ssl-diagnostic-ownership

Conversation

@wasphin

@wasphin wasphin commented Oct 25, 2026

Copy link
Copy Markdown
Member

What problem does this PR solve?

Problem Summary:

Printing an SSL session obtains an owning peer-certificate reference, and printing a certificate allocates a BIO. Repeated diagnostic output retains both resources.

What is changed and the side effects?

Changed:

  • Manage the peer certificate and diagnostic BIO with scoped owners.
  • Add an in-memory TLS regression that verifies the peer certificate is released after repeated diagnostic output.

Side effects:

  • Performance effects: Releases temporary resources after each diagnostic call.
  • Breaking backward compatibility: None for valid inputs.

Check List:

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new regression needs a MesaLink guard because that backend does not emit the certificate fields it asserts.

1 open issue
What changed in this PR

This PR fixes temporary resource leaks in bRPC’s SSL diagnostic output.

Changes:

  • Adds scoped ownership for peer certificates and diagnostic BIO buffers.
  • Adds an in-memory TLS regression checking certificate release after repeated diagnostic output.
File Description
test/​brpc_ssl_unittest.cpp Adds regression coverage for peer-certificate cleanup.
src/​brpc/​details/​ssl_helper.cpp Automatically releases certificate references and BIO buffers.

Review effort: Balanced

Comment thread test/brpc_ssl_unittest.cpp
@wasphin
wasphin requested a lite review from Copilot October 26, 2026 14:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

3 open issues
1 resolved since last review

Review effort: Lite

Comment thread test/brpc_ssl_unittest.cpp
Comment thread test/brpc_ssl_unittest.cpp Outdated
Comment thread src/brpc/details/ssl_helper.cpp Outdated
@wasphin
wasphin requested a lite review from Copilot October 26, 2026 15:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

2 open issues
3 resolved since last review

Review effort: Lite

Comment thread src/brpc/details/ssl_helper.cpp
Comment thread test/brpc_ssl_unittest.cpp
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.

2 participants