aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2024-09-30 11:53:05 +0200
committerMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2024-10-01 09:10:54 +0200
commitfad8e7fba7bf2c523a191309d392cab79668264b (patch)
tree23d91e58e658137f62029ddb4481833b89abb9fd /src
parentfa18586c29d4faba3d3f478eaabf9c4cbc1a16e2 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/node/kernel_notifications.h2
-rw-r--r--src/rpc/server.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/node/kernel_notifications.h b/src/node/kernel_notifications.h
index 71947e5f98..12017f2b2c 100644
--- a/src/node/kernel_notifications.h
+++ b/src/node/kernel_notifications.h
@@ -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);
diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp
index 086f609ac3..ab2135a919 100644
--- a/src/rpc/server.cpp
+++ b/src/rpc/server.cpp
@@ -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");
});
}