-
Notifications
You must be signed in to change notification settings - Fork 170
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
refactor(libsinsp): use smart pointer for m_resolver in sinsp_dns_manager #1558
Conversation
CI Build / build-shared-libs-linux-amd64 🧐 (pull_request) appears to have some tbb linkage issues. |
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.
It seems that we need to keep using a pointer, but a smart pointer now as you can't otherwise truly check if std::thread is empty.
I thought so, after a quick read of the code, that's too bad.
I'm sorry to learn about the tbb linkage issues, I can't understand how they could be related to this change, which LGTM.
#include <gtest/gtest.h> | ||
#include "sinsp_with_test_input.h" | ||
#include <dns_manager.h> |
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 rules for ordering the header files vary a lot from organization to organization. However, there is some consensus in the industry that the headers "closest" to the current compilation unit should go first, then more distant ones such as 3rd party libs and, finally, standard header files. The main reason is that including a system/library header file before the local ones might hide the fact that they miss a critical header for their internal definition, only to be sadly discovered by someone, at some later point in time, who uses these headers in a different context.
According to this idea GTest header should go last in this case.
It's your call whether you feel to embrace this.
As an aside, I think the ordering of headers should be put in the project's coding guidelines.
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.
yes we need the coding guidelines as ... well style is all over the place.
05fc130
to
0cb9311
Compare
No idea about the CI, anyone having a clue why CI Build / build-shared-libs-linux-amd64 🧐 (pull_request) is failing? Edit: That pipeline seems to be wonky across many PRs. |
…ager Signed-off-by: Melissa Kilby <[email protected]>
Signed-off-by: Melissa Kilby <[email protected]>
0cb9311
to
9c63937
Compare
Co-authored-by: Federico Di Pierro <[email protected]> Signed-off-by: Melissa Kilby <[email protected]>
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.
/approve
LGTM label has been added. Git tree hash: 83baf17911bcd54fa34534fae83d2312d3a76e23
|
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.
👍 some very minor questions
*/ | ||
|
||
#if defined(HAS_CAPTURE) && !defined(CYGWING_AGENT) && !defined(_WIN32) && !defined(__EMSCRIPTEN__) | ||
#include "sinsp_with_test_input.h" |
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.
Do we need this include?
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 test is not using it, so TEST_F(sinsp_with_test_input
below is not really necessary.
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.
When we remove this include I think we are ready to go, WDYT?
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.
✔️ from me
TEST_F(sinsp_with_test_input, simple_dns_manager_invocation) | ||
{ | ||
// Simple dummy test to assert that sinsp_dns_manager is invocated correctly | ||
// and not leaking memory |
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.
Do we run the test suite under valgrind in CI? Do we actually detect the (lack of) memory leak?
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.
We run ASan in all libs tests, which will detect memory leaks.
@@ -195,7 +195,7 @@ void sinsp_dns_manager::cleanup() | |||
{ | |||
m_exit_signal.set_value(); | |||
m_resolver->join(); | |||
m_resolver = NULL; | |||
m_resolver.reset(); |
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.
Ouch. Good catch!
std::optional might be an option (hee hee), not sure if it's worth the hassle though. |
Signed-off-by: Melissa Kilby <[email protected]>
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.
/approve
LGTM label has been added. Git tree hash: 2e477a958ad4add52209294e5110b773e5260e3f
|
@gnosek Oh I would prefer not to mess too much with the dns manager as I never looked at it really 🤣 |
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.
LGTM
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: FedeDP, incertum, LucaGuerra The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind bug
/kind cleanup
Any specific area of the project related to this PR?
/area libsinsp
Does this PR require a change in the driver versions?
What this PR does / why we need it:
Follow up #1526 (comment).
It seems that we need to keep using a pointer, but a smart pointer now as you can't otherwise truly check if std::thread is empty.
CC @FedeDP @federico-sysdig @LucaGuerra
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: