瀏覽代碼

Actually do negative caching on failed discovery lookups (fixes #2434)

Jakob Borg 10 年之前
父節點
當前提交
58523060f0
共有 1 個文件被更改,包括 6 次插入0 次删除
  1. 6 0
      lib/discover/cache.go

+ 6 - 0
lib/discover/cache.go

@@ -109,6 +109,12 @@ func (m *CachingMux) Lookup(deviceID protocol.DeviceID) (direct []string, relays
 				when:   time.Now(),
 				when:   time.Now(),
 				found:  len(td)+len(tr) > 0,
 				found:  len(td)+len(tr) > 0,
 			})
 			})
+		} else {
+			// Lookup returned error, add a negative cache entry.
+			m.caches[i].Set(deviceID, CacheEntry{
+				when:  time.Now(),
+				found: false,
+			})
 		}
 		}
 	}
 	}
 	m.mut.Unlock()
 	m.mut.Unlock()