mirror of
https://github.com/tailscale/tailscale.git
synced 2025-10-25 10:09:17 +00:00
Replace time-dependent cache limiting with LRU
To keep memory usage as constant as possible, the previous cache purging at periodic time intervals has been replaced by an LRU that discards the oldest string when the capacity of the cache is reached. Also fixed some formatting and commenting issues, and added better testing for the rate limiter. Signed-off-by: Wendi Yu <wendi.yu@yahoo.ca>
This commit is contained in:
@@ -193,15 +193,15 @@ type testNode struct {
|
||||
func newNode(t *testing.T, prefix string, https *httptest.Server, weirdPrefs bool) testNode {
|
||||
t.Helper()
|
||||
|
||||
ulogfe := func(fmt string, args ...interface{}) {
|
||||
logfe := func(fmt string, args ...interface{}) {
|
||||
t.Logf(prefix+".e: "+fmt, args...)
|
||||
}
|
||||
logfe := logger.RateLimitedFn(ulogfe, 1, 1)
|
||||
logfe := logger.RateLimitedFn(logfe, 1, 1)
|
||||
|
||||
ulogf := func(fmt string, args ...interface{}) {
|
||||
logf := func(fmt string, args ...interface{}) {
|
||||
t.Logf(prefix+": "+fmt, args...)
|
||||
}
|
||||
logf := logger.RateLimitedFn(ulogf, 1, 1)
|
||||
logf := logger.RateLimitedFn(logf, 1, 1, 100)
|
||||
|
||||
var err error
|
||||
httpc := https.Client()
|
||||
|
||||
@@ -40,7 +40,7 @@ func TestRunMultipleAccepts(t *testing.T) {
|
||||
t.Logf(format, args...)
|
||||
}
|
||||
|
||||
logf := logger.RateLimitedFn(ulogf, 1, 1)
|
||||
logf := logger.RateLimitedFn(ulogf, 1, 1, 100)
|
||||
|
||||
connect := func() {
|
||||
for i := 1; i <= 2; i++ {
|
||||
|
||||
Reference in New Issue
Block a user