0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-08 10:31:50 -05:00

refactor: Remove call to StartShutdown from stop RPC

Use SignalInterrupt object instead. There is a slight change in behavior here
because the previous StartShutdown code used to abort on failure and the
new code returns an RPC error instead.
This commit is contained in:
Ryan Ofsky 2023-07-07 17:32:54 -04:00
parent 1d92d89edb
commit 6824eecaf1

View file

@ -8,9 +8,11 @@
#include <common/args.h>
#include <common/system.h>
#include <logging.h>
#include <node/context.h>
#include <rpc/server_util.h>
#include <rpc/util.h>
#include <shutdown.h>
#include <sync.h>
#include <util/signalinterrupt.h>
#include <util/strencodings.h>
#include <util/string.h>
#include <util/time.h>
@ -179,7 +181,7 @@ static RPCHelpMan stop()
{
// Event loop will exit after current HTTP requests have been handled, so
// this reply will get back to the client.
StartShutdown();
CHECK_NONFATAL((*CHECK_NONFATAL(EnsureAnyNodeContext(jsonRequest.context).shutdown))());
if (jsonRequest.params[0].isNum()) {
UninterruptibleSleep(std::chrono::milliseconds{jsonRequest.params[0].getInt<int>()});
}