LibDNS: Check if cached lookup result is done before resolving

This commit is contained in:
rmg-x 2025-02-10 19:05:48 -06:00 committed by Ali Mohammad Pur
commit 1083046f65
Notes: github-actions[bot] 2025-02-11 06:25:23 +00:00

View file

@ -99,6 +99,7 @@ public:
u16 id() { return m_id; } u16 id() { return m_id; }
bool can_be_removed() const { return !m_valid && m_request_done; } bool can_be_removed() const { return !m_valid && m_request_done; }
bool is_done() const { return m_request_done; }
Messages::DomainName const& name() const { return m_name; } Messages::DomainName const& name() const { return m_name; }
private: private:
@ -320,8 +321,12 @@ public:
if (existing_promise) if (existing_promise)
return existing_promise.release_nonnull(); return existing_promise.release_nonnull();
promise->resolve(*result); // Something has gone wrong if there are no pending lookups but the result isn't done.
return promise; // Continue on and hope that we eventually resolve or timeout in that case.
if (result->is_done()) {
promise->resolve(*result);
return promise;
}
} }
Messages::Message query; Messages::Message query;