Linting and fix bug whereby we didn't send updated dl tokens to the client causing a tightloop on /sync sometimes

This commit is contained in:
Kegan Dougal 2020-08-07 13:29:14 +01:00
parent 44a41836f0
commit ed6566b66f
3 changed files with 11 additions and 1 deletions

View file

@ -116,7 +116,7 @@ func (u *DeviceListUpdater) Start() error {
// This is important for sytest as when the /send transaction 200 OKs it assumes that // This is important for sytest as when the /send transaction 200 OKs it assumes that
// keys have been fetched and will then issue requests to /keys/query which it expects // keys have been fetched and will then issue requests to /keys/query which it expects
// to be satisfied from the cache (which it won't be if we haven't processed it yet). // to be satisfied from the cache (which it won't be if we haven't processed it yet).
ch := make(chan gomatrixserverlib.ServerName, 0) ch := make(chan gomatrixserverlib.ServerName)
u.workerChans[i] = ch u.workerChans[i] = ch
go u.worker(ch) go u.worker(ch)
} }

View file

@ -116,6 +116,13 @@ func DeviceListCatchup(
userSet[userID] = true userSet[userID] = true
} }
} }
// set the new token
to.SetLog(DeviceListLogName, &types.LogPosition{
Partition: queryRes.Partition,
Offset: queryRes.Offset,
})
res.NextBatch = to.String()
return hasNew, nil return hasNew, nil
} }

View file

@ -112,6 +112,9 @@ type StreamingToken struct {
} }
func (t *StreamingToken) SetLog(name string, lp *LogPosition) { func (t *StreamingToken) SetLog(name string, lp *LogPosition) {
if t.logs == nil {
t.logs = make(map[string]*LogPosition)
}
t.logs[name] = lp t.logs[name] = lp
} }