fix: restore the intended cs_main scope in FinalizeNode - #7653
Conversation
40906b2 ("partial bitcoin#20228: Make addrman a top-level component", PR dashpay#5163) transposed two lines when backporting upstream 3fc06d3. Upstream opens a scope and takes cs_main inside it: int misbehavior{0}; { LOCK(cs_main); { while the backport landed the LOCK before the scope: int misbehavior{0}; LOCK(cs_main); { { The braces still balance, so this compiled and went unnoticed, but cs_main ended up held for the whole function instead of just that block. The `} // cs_main` marker has been wrong ever since. It stayed harmless because the only code below the marker is CAddrMan::Connected() and a LogPrint, neither of which contends for anything meaningful. It stops being harmless as soon as someone adds work below the marker that takes a contended lock, since the comment says they are outside cs_main when they are not. Restore the upstream shape. No behavior change: nothing below the marker requires cs_main, and misbehavior and nodeid are declared above the scope. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. Walkthrough
Estimated code review effort: 1 (Trivial) | ~2 minutes Merge Risk: ⚪ Minimal · up to This restores the intended cs_main lock scope in FinalizeNode without changing intended behavior; the localized change is merge-ready after normal checks and review, with no actionable merge-blocking risk remaining. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
🕓 Ready for review — 27 ahead in queue (commit 202385c) |
Issue being fixed or feature implemented
40906b2 ("partial bitcoin#20228: Make addrman a top-level component", PR #5163) transposed two lines when backporting upstream 3fc06d3. Upstream opens a scope and takes cs_main inside it:
while the backport landed the LOCK before the scope:
The braces still balance, so this compiled and went unnoticed, but cs_main ended up held for the whole function instead of just that block. The
} // cs_mainmarker has been wrong ever since.It stayed harmless because the only code below the marker is
CAddrMan::Connected()and aLogPrint, neither of which contends for anything meaningful. It stops being harmless as soon as someone adds work below the marker that takes a contended lock, since the comment says they are outside cs_main when they are not.What was done?
Restore the upstream shape. No behavior change: nothing below the marker requires cs_main, and misbehavior and nodeid are declared above the scope. Discovered while reviewing #7563.
How Has This Been Tested?
Breaking Changes
n/a
Checklist: