nomad/rpc listener: modified to throttle logging on "permanent" Accept() errors as well (with a higher delay cap)

This commit is contained in:
Chris Baker
2018-12-07 22:14:15 +00:00
parent 22a4bcd3ca
commit 591cdb00a4

View File

@@ -100,24 +100,20 @@ func (r *rpcHandler) listen(ctx context.Context) {
return
}
select {
case <-ctx.Done():
return
default:
if tempDelay == 0 {
tempDelay = 5 * time.Millisecond
} else {
tempDelay *= 2
}
maxDelay := 5 * time.Second
if ne, ok := err.(net.Error); ok && ne.Temporary() {
if tempDelay == 0 {
tempDelay = 5 * time.Millisecond
} else {
tempDelay *= 2
}
if max := 1 * time.Second; tempDelay > max {
tempDelay = max
}
r.logger.Error("failed to accept RPC conn", "error", err, "delay", tempDelay)
time.Sleep(tempDelay)
maxDelay = 1 * time.Second
}
if tempDelay > maxDelay {
tempDelay = maxDelay
}
r.logger.Error("failed to accept RPC conn", "error", err, "delay", tempDelay)
time.Sleep(tempDelay)
continue
}
tempDelay = 0