diff --git a/src/github.com/matrix-org/dendrite/syncapi/sync/notifier.go b/src/github.com/matrix-org/dendrite/syncapi/sync/notifier.go index 48b0ce378..3df942060 100644 --- a/src/github.com/matrix-org/dendrite/syncapi/sync/notifier.go +++ b/src/github.com/matrix-org/dendrite/syncapi/sync/notifier.go @@ -106,9 +106,8 @@ func (n *Notifier) OnNewEvent(ev *gomatrixserverlib.Event, userID string, pos ty } } -// WaitForEvents blocks until there are events for this request after sincePos. -// In particular, it will return immediately if there are already events after -// sincePos for the request, but otherwise blocks waiting for new events. +// WaitForEvents returns a channel that produces a single stream position when +// a new event *may* be available to return to the client. func (n *Notifier) WaitForEvents(req syncRequest, sincePos types.StreamPosition) <-chan types.StreamPosition { // Do what synapse does: https://github.com/matrix-org/synapse/blob/v0.20.0/synapse/notifier.py#L298 // - Bucket request into a lookup map keyed off a list of joined room IDs and separately a user ID 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 5a32b86b5..a05b9e8fd 100644 --- a/src/github.com/matrix-org/dendrite/syncapi/sync/userstream.go +++ b/src/github.com/matrix-org/dendrite/syncapi/sync/userstream.go @@ -46,8 +46,8 @@ func NewUserStream(userID string, currPos types.StreamPosition) *UserStream { } } -// Wait blocks until there is a new stream position for this user, which is then returned. -// waitAtPos should be the position the stream thinks it should be waiting at. +// Wait returns a channel that produces a single stream position when +// a new event *may* be available to return to the client. func (s *UserStream) Wait(ctx context.Context, waitAtPos types.StreamPosition) <-chan types.StreamPosition { posChannel := make(chan types.StreamPosition, 1) @@ -79,7 +79,7 @@ func (s *UserStream) Wait(ctx context.Context, waitAtPos types.StreamPosition) < if posChannel == ch { lastIdx := len(s.waitingChannels) s.waitingChannels[idx] = s.waitingChannels[lastIdx] - s.waitingChannels[lastIdx] = nil + s.waitingChannels[lastIdx] = nil // Ensure that the channel gets GCed s.waitingChannels = s.waitingChannels[:lastIdx] if len(s.waitingChannels) == 0 {