From ce0ec60fe1b1884690b6479ef20e4125e922db7e Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 24 Oct 2017 11:09:44 +0100 Subject: [PATCH] Add comment and rename variable --- .../matrix-org/dendrite/syncapi/sync/userstream.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/github.com/matrix-org/dendrite/syncapi/sync/userstream.go b/src/github.com/matrix-org/dendrite/syncapi/sync/userstream.go index ef84816a0..8f90b7bfb 100644 --- a/src/github.com/matrix-org/dendrite/syncapi/sync/userstream.go +++ b/src/github.com/matrix-org/dendrite/syncapi/sync/userstream.go @@ -135,9 +135,12 @@ func (s *UserStreamListener) GetNotifyChannel(sincePos types.StreamPosition) <-c defer s.lock.Unlock() if sincePos < s.pos { - posChannel := make(chan struct{}) - close(posChannel) - return posChannel + // If the listener is behind, i.e. missed a potential update, then we + // want them to wake up immediately. We do this by returning a new + // closed stream, which returns immediately when selected. + closedChannel := make(chan struct{}) + close(closedChannel) + return closedChannel } return s.signalChannel