mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-08-28 21:37:45 +02:00
bugfix: Mark m_tip_block_cv as guarded by m_tip_block_mutex
This is not strictly required, but all places using m_tip_block_cv (except shutdown) already take the lock. The annotation makes it easier to catch potential deadlocks before review. Adding the missing lock to the shutdown sequence is a bugfix. An alternative would be to take the lock and release it before notifying, see https://github.com/bitcoin/bitcoin/pull/30967#discussion_r1778899716
This commit is contained in:
@@ -58,7 +58,7 @@ public:
|
||||
bool m_shutdown_on_fatal_error{true};
|
||||
|
||||
Mutex m_tip_block_mutex;
|
||||
std::condition_variable m_tip_block_cv;
|
||||
std::condition_variable m_tip_block_cv GUARDED_BY(m_tip_block_mutex);
|
||||
//! The block for which the last blockTip notification was received for.
|
||||
uint256 m_tip_block GUARDED_BY(m_tip_block_mutex);
|
||||
|
||||
|
@@ -305,7 +305,7 @@ void StopRPC(const std::any& context)
|
||||
DeleteAuthCookie();
|
||||
node::NodeContext& node = EnsureAnyNodeContext(context);
|
||||
// The notifications interface doesn't exist between initialization step 4a and 7.
|
||||
if (node.notifications) node.notifications->m_tip_block_cv.notify_all();
|
||||
if (node.notifications) WITH_LOCK(node.notifications->m_tip_block_mutex, node.notifications->m_tip_block_cv.notify_all());
|
||||
LogDebug(BCLog::RPC, "RPC stopped.\n");
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user