fix(node): fix data race on httpConfig.prefix #32047#2000
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the
✨ 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 |
There was a problem hiding this comment.
Pull request overview
Fixes a data race on the RPC path prefix by snapshotting the configured prefix into the immutable RPC handler stored in an atomic pointer, so request handling no longer reads mutable server config concurrently.
Changes:
- Add
prefixtorpcHandlerand use it for request routing (checkPath) instead of readinghttpConfig/wsConfigduringServeHTTP. - Replace
atomic.Valuehandler storage with typedatomic.Pointer[rpcHandler]for safer, simpler nil handling.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This fixes a data race when accessing the `httpConfig.prefix` field. This field can be modified while the server is running through `enableRPC`. The fix is storing the prefix in the handler, which is accessed through the atomic pointer. alternative to ethereum#32035 fixes ethereum#32019
5614931 to
8135831
Compare
This fixes a data race when accessing the `httpConfig.prefix` field. This field can be modified while the server is running through `enableRPC`. The fix is storing the prefix in the handler, which is accessed through the atomic pointer. alternative to ethereum#32035 fixes ethereum#32019 Co-authored-by: Felix Lange <fjl@twurst.com>
Proposed changes
This fixes a data race when accessing the
httpConfig.prefixfield. This field can be modified while the server is running throughenableRPC. The fix is storing the prefix in the handler, which is accessed through the atomic pointer.Ref: ethereum#32047
Types of changes
What types of changes does your code introduce to XDC network?
Put an
✅in the boxes that applyImpacted Components
Which part of the codebase this PR will touch base on,
Put an
✅in the boxes that applyChecklist
Put an
✅in the boxes once you have confirmed below actions (or provide reasons on not doing so) that