LibDNS: Fix deadlock when receiving invalid lookup result

Previously, we would stop the repeat timer even if we got a null result.
This caused the pending lookup to:
- Never resolve, and
- Never get purged for too many retries

I believe the underlying issue is something on the socket level, but we
should handle this case regardless.
This commit is contained in:
rmg-x 2024-11-29 13:59:49 -06:00 committed by Andreas Kling
parent 3f5e32ee84
commit 4a16c89603
Notes: github-actions[bot] 2024-12-01 10:36:50 +00:00

View file

@ -453,10 +453,11 @@ private:
if (!lookup)
return Error::from_string_literal("No pending lookup found for this message");
lookup->repeat_timer->stop();
if (lookup->result.is_null())
return {}; // Message is a response to a lookup that's been purged from the cache, ignore it
lookup->repeat_timer->stop();
auto result = lookup->result.strong_ref();
for (auto& record : message.answers)
result->add_record(move(record));