diff options
author | 2018-05-26 01:00:11 +0300 | |
---|---|---|
committer | 2018-05-25 23:00:11 +0100 | |
commit | 833e3ddaf07204f32fa3e4b71583d158a074d34a (patch) | |
tree | 1c7446bae6c5de846970c90d09c91ceb410df731 /test/cache_test.go | |
parent | 94ced8255b42c90b934f0aa106ea813dcdeaae52 (diff) | |
download | coredns-833e3ddaf07204f32fa3e4b71583d158a074d34a.tar.gz coredns-833e3ddaf07204f32fa3e4b71583d158a074d34a.tar.zst coredns-833e3ddaf07204f32fa3e4b71583d158a074d34a.zip |
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
Diffstat (limited to 'test/cache_test.go')
0 files changed, 0 insertions, 0 deletions