diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2022-04-08 10:46:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-08 10:46:36 +0100 |
commit | f299f97e0ad8ad73f7745d8896f017d939f7b9df (patch) | |
tree | 1e4ec26834f5c88a5692e26ae8005828d34b84d9 /syncapi/notifier | |
parent | b8c97431b9baa59fed4d044cbff7d609ab2fd9cb (diff) |
Fix data race in `TestCorrectStreamWakeup` (#2334)
Diffstat (limited to 'syncapi/notifier')
-rw-r--r-- | syncapi/notifier/notifier_test.go | 4 | ||||
-rw-r--r-- | syncapi/notifier/userstream.go | 6 |
2 files changed, 8 insertions, 2 deletions
diff --git a/syncapi/notifier/notifier_test.go b/syncapi/notifier/notifier_test.go index 2273ad76..b0631371 100644 --- a/syncapi/notifier/notifier_test.go +++ b/syncapi/notifier/notifier_test.go @@ -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" } }() diff --git a/syncapi/notifier/userstream.go b/syncapi/notifier/userstream.go index 720185d5..bcd69fad 100644 --- a/syncapi/notifier/userstream.go +++ b/syncapi/notifier/userstream.go @@ -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 { |