aboutsummaryrefslogtreecommitdiff
path: root/keyserver
diff options
context:
space:
mode:
authorKegsay <kegan@matrix.org>2020-08-12 10:50:52 +0100
committerGitHub <noreply@github.com>2020-08-12 10:50:52 +0100
commitb8b854d64201a8c40956bddc84d8a0844221bf7d (patch)
tree1315ac9335d64be9918b4952cef7d0fec840031a /keyserver
parentbcdf9577a3db0727b4966cfdd3c4471ca6d3f1f6 (diff)
Bugfixes for 'If remote user leaves room we no longer receive device updates' (#1262)
* Bugfixes for 'If remote user leaves room we no longer receive device updates' * Update whitelist and README
Diffstat (limited to 'keyserver')
-rw-r--r--keyserver/internal/device_list_update.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/keyserver/internal/device_list_update.go b/keyserver/internal/device_list_update.go
index c4b098a4..85785b07 100644
--- a/keyserver/internal/device_list_update.go
+++ b/keyserver/internal/device_list_update.go
@@ -230,6 +230,7 @@ func (u *DeviceListUpdater) worker(ch chan gomatrixserverlib.ServerName) {
}
// on failure, spin up a short-lived goroutine to inject the server name again.
+ scheduledRetries := make(map[gomatrixserverlib.ServerName]time.Time)
inject := func(srv gomatrixserverlib.ServerName, duration time.Duration) {
time.Sleep(duration)
ch <- srv
@@ -237,13 +238,20 @@ func (u *DeviceListUpdater) worker(ch chan gomatrixserverlib.ServerName) {
for serverName := range ch {
if !shouldProcess(serverName) {
- // do not inject into the channel as we know there will be a sleeping goroutine
- // which will do it after the cooloff period expires
- continue
+ if time.Now().Before(scheduledRetries[serverName]) {
+ // do not inject into the channel as we know there will be a sleeping goroutine
+ // which will do it after the cooloff period expires
+ continue
+ } else {
+ scheduledRetries[serverName] = time.Now().Add(cooloffPeriod)
+ go inject(serverName, cooloffPeriod) // TODO: Backoff?
+ continue
+ }
}
lastProcessed[serverName] = time.Now()
shouldRetry := u.processServer(serverName)
if shouldRetry {
+ scheduledRetries[serverName] = time.Now().Add(cooloffPeriod)
go inject(serverName, cooloffPeriod) // TODO: Backoff?
}
}