Skip to content

Commit 072f7ed

Browse files
facontidavideclaude
andcommitted
docs: Document lock ordering hierarchy in BridgeServer
Prevents future changes from introducing deadlocks by documenting the implicit ordering: cleanup_mutex_ > last_sent_mutex_ > stats_mutex_. WebSocketMiddleware ordering was documented in an earlier commit. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: 00acef786069
1 parent d0ab1aa commit 072f7ed

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

include/pj_ros_bridge/bridge_server.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,10 @@ class BridgeServer {
148148
// Message stripping configuration
149149
bool strip_large_messages_;
150150

151-
// Protects cleanup_session from concurrent calls (disconnect + timeout)
151+
// Lock ordering (to prevent deadlock):
152+
// cleanup_mutex_ > last_sent_mutex_ > stats_mutex_
153+
// SessionManager::mutex_ may be acquired while holding any of these.
154+
// Never acquire a higher-order lock while holding a lower-order one.
152155
std::mutex cleanup_mutex_;
153156

154157
// Per-client per-topic last-sent timestamp (nanoseconds) for rate limiting

0 commit comments

Comments
 (0)