resolver: Fix infinite debug printing loop, if client disconnects

This commit is contained in:
Bananymous 2024-07-16 15:05:07 +03:00
parent dd7bfba8d5
commit 61f0043cd8
1 changed files with 11 additions and 1 deletions

View File

@ -286,13 +286,23 @@ int main(int, char**)
if (!client.query.empty()) if (!client.query.empty())
{ {
static uint8_t buffer[4096];
ssize_t nrecv = recv(client.socket, buffer, sizeof(buffer), 0);
if (nrecv < 0)
dprintln("{}", strerror(errno));
if (nrecv <= 0)
client.close = true;
else
dprintln("Client already has a query"); dprintln("Client already has a query");
continue; continue;
} }
auto query = read_service_query(client.socket); auto query = read_service_query(client.socket);
if (!query.has_value()) if (!query.has_value())
{
client.close = true;
continue; continue;
}
BAN::Optional<DNSEntry> result; BAN::Optional<DNSEntry> result;