mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-21 05:43:09 -06:00
Review comments
This commit is contained in:
parent
5f96a859e1
commit
a3c11b21c7
|
|
@ -77,7 +77,7 @@ func failBlacklistableError(err error, stats *statistics.ServerStatistics) {
|
|||
stats.Failure()
|
||||
return
|
||||
}
|
||||
if mxerr.Code == 500 {
|
||||
if mxerr.Code >= 500 || mxerr.Code < 600 {
|
||||
stats.Failure()
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,11 +97,22 @@ func (s *ServerStatistics) Failure() {
|
|||
|
||||
// BackoffIfRequired will block for as long as the current
|
||||
// backoff requires, if needed. Otherwise it will do nothing.
|
||||
// Returns the amount of time to backoff for and whether to give up or not.
|
||||
func (s *ServerStatistics) BackoffIfRequired(backingOff atomic.Bool, interrupt <-chan bool) (time.Duration, bool) {
|
||||
if started := s.backoffStarted.Load(); !started {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
// Check if the interrupt channel is already closed. If it is
|
||||
// then this call should have no side effects but still return
|
||||
// the current duration.
|
||||
select {
|
||||
case <-interrupt:
|
||||
count := s.backoffCount.Load()
|
||||
return time.Second * time.Duration(math.Exp2(float64(count))), false
|
||||
default:
|
||||
}
|
||||
|
||||
// Work out how many times we've backed off so far.
|
||||
count := s.backoffCount.Inc()
|
||||
duration := time.Second * time.Duration(math.Exp2(float64(count)))
|
||||
|
|
|
|||
Loading…
Reference in a new issue