This change drops shutdown.h
and shutdown.cpp
files, replacing them with a NodeContext::shutdown
member which is used to trigger shutdowns directly. This gets rid of an unnecessary layer of indirection, and allows getting rid of the kernel::g_context
global.
Additionally, this PR tries to improve error handling of SignalInterrupt
code by marking relevant methods [[nodiscard]]
to avoid the possibility of uncaught exceptions mentioned #27861 (review).
Behavior is changing In a few cases which are noted in individual commit messages. Particularly: GUI code more consistently interrupts RPCs when it is shutting down, shutdown state no longer persists between unit tests, the stop RPC now returns an RPC error if requesting shutdown fails instead of aborting, and other failed shutdown calls now log errors instead of aborting.
This PR is a net reduction in lines of code, but in some cases the explicit error handling and lack of global shutdown functions do make it more verbose. The verbosity can be seen as good thing if it discourages more code from directly triggering shutdowns, and instead encourages code to return errors or send notifications that could be translated into shutdowns. Probably a number of existing shutdown calls could just be replaced by better error handling.