mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-07 15:03:09 -06:00
Don't fully fill the buffer
This commit is contained in:
parent
999463a80e
commit
9df2b9a69d
|
|
@ -419,12 +419,19 @@ func (u *DeviceListUpdater) worker(ch chan spec.ServerName, workerID int) {
|
||||||
var serversToRetry []spec.ServerName
|
var serversToRetry []spec.ServerName
|
||||||
for {
|
for {
|
||||||
deviceListUpdaterServersRetrying.With(prometheus.Labels{"worker_id": strconv.Itoa(workerID)}).Set(float64(len(retries)))
|
deviceListUpdaterServersRetrying.With(prometheus.Labels{"worker_id": strconv.Itoa(workerID)}).Set(float64(len(retries)))
|
||||||
serversToRetry = serversToRetry[:0] // reuse memory
|
|
||||||
time.Sleep(time.Second * 2)
|
time.Sleep(time.Second * 2)
|
||||||
|
|
||||||
|
// The channel is at capacity, don't try to send more work
|
||||||
if len(ch) == cap(ch) {
|
if len(ch) == cap(ch) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
maxServers := cap(ch) - len(ch)
|
serversToRetry = serversToRetry[:0] // reuse memory
|
||||||
|
|
||||||
|
// -2, so we have space for incoming device list updates over federation
|
||||||
|
maxServers := (cap(ch) - len(ch)) - 2
|
||||||
|
if maxServers <= 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
retriesMu.Lock()
|
retriesMu.Lock()
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue