Skip to content

Commit

Permalink
Merge pull request #880 from ekcasey/fix-eventstream-race-condition
Browse files Browse the repository at this point in the history
Fixes race condition in EventStream
  • Loading branch information
rogeralsing authored Aug 12, 2023
2 parents c163360 + 1bae8af commit 3987052
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion eventstream/eventstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ func (es *EventStream) Publish(evt interface{}) {

// Returns an integer that represents the current number of subscribers to the stream
func (es *EventStream) Length() int32 {
return atomic.LoadInt32(&es.counter)
es.RLock()
defer es.RUnlock()
return es.counter
}

// Subscription is returned from the Subscribe function.
Expand Down

0 comments on commit 3987052

Please sign in to comment.