-
Notifications
You must be signed in to change notification settings - Fork 905
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
fix(userspace/falco): make termination and signal handlers more stable #2239
Conversation
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
…able Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
/milestone 0.33.0 |
if(! create_handler(SIGINT, ::terminate_signal_handler, ret) || | ||
! create_handler(SIGTERM, ::terminate_signal_handler, ret) || | ||
! create_handler(SIGUSR1, ::reopen_outputs_signal_handler, ret) || | ||
! create_handler(SIGHUP, ::restart_signal_handler, ret)) |
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.
what about something like:
if(! create_handler(SIGINT, ::terminate_signal_handler, ret) || | |
! create_handler(SIGTERM, ::terminate_signal_handler, ret) || | |
! create_handler(SIGUSR1, ::reopen_outputs_signal_handler, ret) || | |
! create_handler(SIGHUP, ::restart_signal_handler, ret)) | |
return !create_handler(SIGINT, ::terminate_signal_handler, ret) || | |
!create_handler(SIGTERM, ::terminate_signal_handler, ret) || | |
!create_handler(SIGUSR1, ::reopen_outputs_signal_handler, ret) || | |
!create_handler(SIGHUP, ::restart_signal_handler, ret)) ? run_result::fatal("") : run_result::ok(); |
Or if we don't want to return fatal just run_result::ok()
in both cases 🤔 just a nitpick feel free to ignore
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.
create_handler
already sets its own error results in the passed-in ret
, so errors are already catched.
… times Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
…ailures Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
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: 9c46687de8ccdb55ef0497400ebf1d701f2787ec
|
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
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Andreagit97, FedeDP, jasondellaluce 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 engine
What this PR does / why we need it:
Signal handlers are used in Falco to force termination, hot reload, or output reloading. However, the current implementation is not stable for neither thread-safety and async-signal safety (more here: https://docs.oracle.com/cd/E19455-01/806-5257/gen-26/index.html). This PR refactors the way signals are handled to make sure it's safe both on single-threaded (e.g. capturing only syscalls) and multi-threaded use cases (e.g. multiple event sources in parallel).
Accordingly, the event source termination stage has been refactored to be more stable by using atomic values to check 1) that the event source has actually finished processing events, and 2) that the corresponding thread has already been joined. This is safer than simply relying on the
thread.joinable()
andthread.join()
primitives.Which issue(s) this PR fixes:
Special notes for your reviewer:
Does this PR introduce a user-facing change?: