Repository navigation
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
Static review found no blocking issues in the focused race fix or boundary coverage; tests were not run.
No open issues 🎉
What changed in this PR
Removes the socket’s cached overcrowding flag to eliminate a data race and derive write-admission state directly from the atomic pending-byte count.
Changes:
- Derive overcrowding from
_unwritten_bytes. - Update write checks and debug output.
- Add threshold-boundary coverage.
Review effort: Balanced
wwbmmm
left a comment
There was a problem hiding this comment.
[replied by brpc-oncall robot] The derivation of the overcrowding state from the atomic _unwritten_bytes is sound and removes the racy volatile bool; only two minor points, no blocker. Also please update the leftover comment in Socket::KeepWrite ("...may turn on _overcrowded to stop pending requests from growing infinitely"), which no longer describes how the state is produced.

What problem does this PR solve?
Issue Number: resolve
Problem Summary:
Socketmaintains_unwritten_bytesas the source of truth for pendingoutput, but also caches the overcrowding state in a separate
volatile boolnamed
_overcrowded.WriteRequest::Setup()andCancelUnwrittenBytes()can update this cachedboolean concurrently with
Socket::Write()reading it.volatiledoes notprovide synchronization, so these accesses form a C++ data race. The cached
state can also become stale when concurrent increment and decrement paths
overwrite each other.
What is changed and the side effects?
Changed:
_overcrowdedcached boolean._unwritten_bytes.is_overcrowded()in write admission checks and socket debug output.-socket_max_unwritten_bytes.Update the KeepWrite comment and exercise overcrowding transitions through
the public socket write path.
Side effects:
Performance effects:
Breaking backward compatibility:
Check List: