Skip to content

Conversation

@heifner
Copy link
Contributor

@heifner heifner commented Jan 28, 2025

Spring creates the controller in chain_plugin::plugin_initialize. If ctrl-c is pressed during chain_plugin::plugin_initialize chainbase can be left with a dirty-db flag.

  • Move initialization of signal handing to appbase::initialize so that it is in affect during plugin_initialize.
  • Do not cancel and restart the signal_set to remove SIGHUP from the signal set. This was technically not thread-safe before. The boost docs indicate shared objects are not thread-safe. Since we discussed before that there was no real reason to treat SIGHUP differently during startup, I just removed the cancel/restart. This makes it thread-safe and simplifies the implementation.

@heifner heifner added the OCI Work exclusive to OCI team label Jan 28, 2025
@greg7mdp
Copy link
Contributor

I'm wondering, in chain_plugin_impl::plugin_startup(), we can do long processing like loading a snapshot I think. Can we still ^C out of it?

@heifner
Copy link
Contributor Author

heifner commented Jan 28, 2025

I'm wondering, in chain_plugin_impl::plugin_startup(), we can do long processing like loading a snapshot I think. Can we still ^C out of it?

Yes, the signal handling is now in affect from appbase::initialize on, including chain_plugin_impl::plugin_startup().

std::string plugin_name;
auto error_header = [&]() { return std::string("appbase: exception thrown during plugin \"") + plugin_name + "\" initialization.\n"; };

// setup handling of SIGINT/SIGTERM/SIGPIPE/SIGHUP during initialize
Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose this comment should have SIGHUP removed because setup_signal_handling_on_ioc() doesn't handle SIGHUP now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. I actually updated the comment that was removed.

@spoonincode
Copy link
Contributor

spoonincode commented Jan 28, 2025

I don't think you can ^C out of loading a snapshot because I don't believe snapshot loading code polls is_quitting(). Instead the ^C will just be queued up to be handled after it's done

EDIT: well technically not queued up since it was already delivered to the async_wait thread

@heifner
Copy link
Contributor Author

heifner commented Jan 28, 2025

I don't think you can ^C out of loading a snapshot because I don't believe snapshot loading code polls is_quitting(). Instead the ^C will just be queued up to be handled after it's done

Related: AntelopeIO/spring#798 (comment)

@heifner heifner force-pushed the init-signal-handling branch from 5b61671 to bbd74cc Compare January 28, 2025 02:05
@heifner heifner merged commit 74ac065 into main Jan 28, 2025
4 checks passed
@heifner heifner deleted the init-signal-handling branch January 28, 2025 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCI Work exclusive to OCI team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants