You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use lock-based sweep to eliminate pending request race condition
Replace the volatile flag + double-sweep approach with a lock that makes
the completion flag set + sweep in ProcessMessagesCoreAsync mutually
exclusive with the flag check in SendRequestAsync. This ensures that
either the sweep finds the TCS, or SendRequestAsync sees the flag, even
if ConcurrentDictionary's non-atomic iteration (which traverses buckets
one-by-one without locks) races with a concurrent add.
The lock also provides full memory barriers on all architectures,
eliminating any potential store/load visibility concerns that the
volatile-only approach may have had under certain timing conditions.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
0 commit comments