Skip to content

Commit

Permalink
Fix data race on simplifiedEventBus.bus
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Litvinov <[email protected]>
  • Loading branch information
Zensey committed Mar 21, 2024
1 parent fe72e46 commit 1c6d7c3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion eventbus/event_bus.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,11 @@ func (b *simplifiedEventBus) Publish(topic string, data interface{}) {

b.mu.RLock()
ids := b.sub[topic]
idsCopy := make([]string, len(ids))
copy(idsCopy, ids)
b.mu.RUnlock()

for _, id := range ids {
for _, id := range idsCopy {
b.bus.Publish(topic+id, data)
}
}
Expand Down

0 comments on commit 1c6d7c3

Please sign in to comment.