diff --git a/src/index/base.cpp b/src/index/base.cpp index 8fe30f89601..e134ad6bce5 100644 --- a/src/index/base.cpp +++ b/src/index/base.cpp @@ -151,9 +151,9 @@ void BaseIndex::ThreadSync() const CBlockIndex* pindex_next = NextSyncBlock(pindex, m_chainstate->m_chain); if (!pindex_next) { m_best_block_index = pindex; - m_synced = true; // No need to handle errors in Commit. See rationale above. Commit(); + m_synced = true; break; } if (pindex_next->pprev != pindex && !Rewind(pindex, pindex_next->pprev)) { diff --git a/src/init.cpp b/src/init.cpp index eac326fae83..27addf275aa 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -238,9 +238,9 @@ void Shutdown(NodeContext& node) // After everything has been shut down, but before things get flushed, stop the // CScheduler/checkqueue, scheduler and load block thread. + if (node.chainman && node.chainman->m_load_block.joinable()) node.chainman->m_load_block.join(); if (node.scheduler) node.scheduler->stop(); if (node.reverification_scheduler) node.reverification_scheduler->stop(); - if (node.chainman && node.chainman->m_load_block.joinable()) node.chainman->m_load_block.join(); StopScriptCheckWorkerThreads(); // After the threads that potentially access these pointers have been stopped, diff --git a/src/net.cpp b/src/net.cpp index 1b0e7369a37..5cd7e0e7642 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2221,7 +2221,7 @@ std::vector CConnman::GetAddedNodeInfo() const } for (const std::string& strAddNode : lAddresses) { - CService service(LookupNumeric(strAddNode, Params().GetDefaultPort(strAddNode))); + CService service{MaybeFlipIPv6toCJDNS(LookupNumeric(strAddNode, Params().GetDefaultPort(strAddNode)))}; AddedNodeInfo addedNode{strAddNode, CService(), false, false}; if (service.IsValid()) { // strAddNode is an IP:port diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 972e85098dc..b20765a9e29 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -279,12 +279,12 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* tip, const CBlockIn const CTxUndo* txundo = (have_undo && i > 0) ? &blockUndo.vtxundo.at(i - 1) : nullptr; UniValue objTx(UniValue::VOBJ); TxToUniv(*tx, uint256(), objTx, true, RPCSerializationFlags(), txundo, verbosity); - txs.push_back(objTx); + txs.push_back(std::move(objTx)); } break; } - result.pushKV("tx", txs); + result.pushKV("tx", std::move(txs)); return result; } diff --git a/src/rpc/request.cpp b/src/rpc/request.cpp index f332eaa46b0..7d99fe088ba 100644 --- a/src/rpc/request.cpp +++ b/src/rpc/request.cpp @@ -78,6 +78,8 @@ static fs::path GetAuthCookieFile(bool temp=false) return AbsPathForConfigVal(fs::PathFromString(arg)); } +static bool g_generated_cookie = false; + bool GenerateAuthCookie(std::string *cookie_out) { const size_t COOKIE_SIZE = 32; @@ -103,6 +105,7 @@ bool GenerateAuthCookie(std::string *cookie_out) LogPrintf("Unable to rename cookie authentication file %s to %s\n", fs::PathToString(filepath_tmp), fs::PathToString(filepath)); return false; } + g_generated_cookie = true; LogPrintf("Generated RPC authentication cookie %s\n", fs::PathToString(filepath)); if (cookie_out) @@ -168,7 +171,10 @@ bool GetMainchainAuthCookie(std::string *cookie_out) void DeleteAuthCookie() { try { - fs::remove(GetAuthCookieFile()); + if (g_generated_cookie) { + // Delete the cookie file if it was generated by this process + fs::remove(GetAuthCookieFile()); + } } catch (const fs::filesystem_error& e) { LogPrintf("%s: Unable to remove random auth cookie file: %s\n", __func__, fsbridge::get_filesystem_error_message(e)); } diff --git a/test/functional/feature_filelock.py b/test/functional/feature_filelock.py index 945ece6a33f..9e3939f1010 100755 --- a/test/functional/feature_filelock.py +++ b/test/functional/feature_filelock.py @@ -27,7 +27,8 @@ def run_test(self): self.log.info("Check that we can't start a second bitcoind instance using the same datadir") expected_msg = f"Error: Cannot obtain a lock on data directory {datadir}. {self.config['environment']['PACKAGE_NAME']} is probably already running." self.nodes[1].assert_start_raises_init_error(extra_args=[f'-datadir={self.nodes[0].datadir}', '-noserver'], expected_msg=expected_msg) - + cookie_file = datadir + "/.cookie" + assert os.path.isfile(cookie_file) # should not be deleted during the second bitcoind instance shutdown if self.is_wallet_compiled(): def check_wallet_filelock(descriptors): wallet_name = ''.join([random.choice(string.ascii_lowercase) for _ in range(6)])