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

prevent leaking of CURL handles #36

Merged
merged 1 commit into from
May 31, 2023
Merged

Conversation

dgoffredo
Copy link
Contributor

See #31.

In addition to the recommended change, this revision also adds unit tests that verify that a CURL handle, once created, is destroyed.

@dgoffredo dgoffredo requested a review from cgilmour May 18, 2023 22:21
user_data_on_write_ = data;
return CURLE_OK;
}
class SingleRequestMockCurlLibrary : public CurlLibrary {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This code is moved and renamed from the class MockCurlLibrary that used to be in the TEST_CASE("parse response headers and body"). It's used there and in the new test case.

I also added data members created_handles_, destroyed_handles_, message_result_, and delay_message_.

@pr-commenter
Copy link

pr-commenter bot commented May 18, 2023

Benchmarks

Comparing candidate commit 2c261a4 in PR branch david.goffredo/curl-handle-leak with baseline commit 338a87e in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 1 metrics, 0 unstable metrics.

Comment on lines +431 to +433
// Here are the checks relevant to this test.
REQUIRE(library.created_handles_.size() == 1);
REQUIRE(library.created_handles_ == library.destroyed_handles_);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The SECTIONs above are all setup. The post-condition, here, is always the same: one handle created and one handle destroyed.

@dgoffredo
Copy link
Contributor Author

I find that "hide whitespace" in the diff gearbox menu improves the diff.

Copy link
Contributor

@cgilmour cgilmour left a comment

Choose a reason for hiding this comment

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

Seems OK, marking as approved.
Are there any consequences to doing this with a request in-flight?

@dgoffredo
Copy link
Contributor Author

Thanks!

Are there any consequences to doing this with a request in-flight?

Nope, removing the easy handle from the multi-handle (event loop) unregisters it from anything that would drive its installed callbacks. Then cleaning up the easy handle frees resources.

@dgoffredo dgoffredo merged commit ec35054 into main May 31, 2023
@dgoffredo dgoffredo deleted the david.goffredo/curl-handle-leak branch May 31, 2023 13:28
cataphract pushed a commit to cataphract/dd-trace-cpp that referenced this pull request Mar 28, 2024
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