mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 02:33:14 -04:00
plugin/forward: erase expired connections by timer (#1782)
* plugin/forward: erase expired connection by timer - in previous implementation, the expired connections resided in cache until new request to the same upstream/protocol came. In case if the upstream was unhealthy new request may come long time later or may not come at all. All this time expired connections held system resources (file descriptors, ephemeral ports). In my fix the expired connections and related resources are released by timer - decreased the complexity of taking connection from cache. The list of connections is treated as stack (LIFO queue), i.e. the connection is taken from the end of queue (the most fresh connection) and returned to the end (as it was implemented before). The remarkable thing is that all connections in the stack appear to be ordered by 'used' field - the cleanup() method finds the first good (not expired) connection in stack with binary search, since all connections are ordered by 'used' field * fix race conditions * minor enhancement * add comments
This commit is contained in:
committed by
Miek Gieben
parent
94ced8255b
commit
833e3ddaf0
@@ -100,7 +100,10 @@ func (p *Proxy) finalizer() {
|
||||
}
|
||||
|
||||
// start starts the proxy's healthchecking.
|
||||
func (p *Proxy) start(duration time.Duration) { p.probe.Start(duration) }
|
||||
func (p *Proxy) start(duration time.Duration) {
|
||||
p.probe.Start(duration)
|
||||
p.transport.Start()
|
||||
}
|
||||
|
||||
const (
|
||||
dialTimeout = 4 * time.Second
|
||||
|
||||
Reference in New Issue
Block a user