Fix data race in TestCorrectStreamWakeup

This commit is contained in:
Neil Alexander 2022-04-08 10:35:32 +01:00
parent 63b7c3da46
commit 81d9166d52
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
2 changed files with 8 additions and 2 deletions

View file

@ -165,9 +165,9 @@ func TestCorrectStreamWakeup(t *testing.T) {
go func() {
select {
case <-streamone.signalChannel:
case <-streamone.ch():
awoken <- "one"
case <-streamtwo.signalChannel:
case <-streamtwo.ch():
awoken <- "two"
}
}()

View file

@ -118,6 +118,12 @@ func (s *UserDeviceStream) TimeOfLastNonEmpty() time.Time {
return s.timeOfLastChannel
}
func (s *UserDeviceStream) ch() <-chan struct{} {
s.lock.Lock()
defer s.lock.Unlock()
return s.signalChannel
}
// GetSyncPosition returns last sync position which the UserStream was
// notified about
func (s *UserDeviceStreamListener) GetSyncPosition() types.StreamingToken {