From a24088e17ba3f792125223411ffa820a2b05539a Mon Sep 17 00:00:00 2001 From: Peter Cai Date: Tue, 6 Apr 2021 11:16:12 +0800 Subject: [PATCH] cache: handle stale list result --- src/cache.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/cache.rs b/src/cache.rs index ca7aae2..7fad0ff 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -86,7 +86,15 @@ impl DnsCache { )); } - Some(ret) + if ret.len() == 0 { + // Sometimes the KV list operation may return stale keys that + // are no longer valid, resulting in we skipping over them in + // the main loop above. This could result in a non-empty + // keys array but an empty return value. + None + } else { + Some(ret) + } } fn record_to_key(record: &Record>, OwnedRecordData>, buf: &[u8]) -> String {