mirror of
https://github.com/jeremyd/ergo.git
synced 2026-05-25 09:14:47 -07:00
The rationale for why regenerateMembersCache didn't need to hold the Lock() throughout was subtly wrong. It is true that at least some attempt to regenerate the cache would see *all* the updates. However, it was possible for the value of `result` generated by that attempt to lose the race for the final assignment `channel.membersCache = result`. The fix is to serialize the attempts to regenerate the cache, without adding any additional locking on the underlying `Channel` fields via `Channel.stateMutex`. This ensures that the final read from `Channel.members` is paired with the final write to `Channel.membersCache`.
22 KiB
22 KiB