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

fix: better exit behavior with plugin sources #1867

Merged
merged 1 commit into from
Apr 26, 2022
Merged

fix: better exit behavior with plugin sources #1867

merged 1 commit into from
Apr 26, 2022

Conversation

ldegio
Copy link
Contributor

@ldegio ldegio commented Apr 13, 2022

When using a source plugin, force an exit only if the plugin is actually stuck on a next(), not if it's working on the close()

Signed-off-by: Loris Degioanni loris@sysdig.com

…actually stuck on a next(), not if its working on the close()

Signed-off-by: Loris Degioanni <loris@sysdig.com>
// When we are using one, check again in few seconds and force a quit
// if we are stuck.
//
if(g_terminate == true)
if(g_terminate == true && g_terminating == false)
Copy link
Contributor

@FedeDP FedeDP Apr 14, 2022

Choose a reason for hiding this comment

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

If i undestand the code correctly:

  • if signal_callback is called while a plugin is inside next, we set g_terminate to true, and wait 3 more seconds

  • then, if the plugin is still frozen inside next, we will exit the program (because g_terminating will still be false)

  • If, instead, during those 3 seconds, we are now in g_terminating mode (ie: we are closing the live capture), what is supposed to happen here?
    We will have both g_terminate and g_terminating true, and we will loop on alarm(3); forever, right?

Perhaps i am missing some pieces here :)

Copy link
Contributor Author

@ldegio ldegio Apr 21, 2022

Choose a reason for hiding this comment

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

correct. The idea is:

  • if g_terminating doesn't get set, it means a plugin (or, more generally, the reader) is stuck on open() or next(). We assume such behavior is not good and in that case we exit
  • if g_terminating is set, it means that the plugin is working on close(). We assume it's well behaved and it will eventually return (cleanup can take time) and we just let it go forever

Copy link
Contributor

Choose a reason for hiding this comment

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

I see now, thanks!

Copy link
Contributor

@FedeDP FedeDP left a comment

Choose a reason for hiding this comment

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

/approve

@FedeDP FedeDP merged commit ca06d4d into dev Apr 26, 2022
@FedeDP FedeDP deleted the exit-fix branch April 26, 2022 10:09
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