This commit is contained in:
Neil Alexander 2021-01-29 12:55:12 +00:00
parent 9b6e807f82
commit f68abcdb54
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -2,6 +2,7 @@ package streams
import ( import (
"context" "context"
"sync"
"github.com/matrix-org/dendrite/syncapi/types" "github.com/matrix-org/dendrite/syncapi/types"
userapi "github.com/matrix-org/dendrite/userapi/api" userapi "github.com/matrix-org/dendrite/userapi/api"
@ -54,7 +55,7 @@ func (p *PDUStreamProvider) CompleteSync(
// Build up a /sync response. Add joined rooms. // Build up a /sync response. Add joined rooms.
var reqMutex sync.Mutex var reqMutex sync.Mutex
var reqWaitGroup sync.WaitGroup var reqWaitGroup sync.WaitGroup
reqWaitGroup.add(len(joinedRooms)) reqWaitGroup.Add(len(joinedRooms))
for _, roomID := range joinedRoomIDs { for _, roomID := range joinedRoomIDs {
go func() { go func() {
defer reqWaitGroup.Done() defer reqWaitGroup.Done()
@ -64,7 +65,7 @@ func (p *PDUStreamProvider) CompleteSync(
) )
if err != nil { if err != nil {
req.Log.WithError(err).Error("p.getJoinResponseForCompleteSync failed") req.Log.WithError(err).Error("p.getJoinResponseForCompleteSync failed")
return from return //from
} }
reqMutex.Lock() reqMutex.Lock()
defer reqMutex.Unlock() defer reqMutex.Unlock()