diff --git a/Userland/Services/LookupServer/MulticastDNS.cpp b/Userland/Services/LookupServer/MulticastDNS.cpp index 75f26c54f0..adc912a140 100644 --- a/Userland/Services/LookupServer/MulticastDNS.cpp +++ b/Userland/Services/LookupServer/MulticastDNS.cpp @@ -44,26 +44,28 @@ MulticastDNS::MulticastDNS(Object* parent) bind(IPv4Address(), 5353); on_ready_to_receive = [this]() { - handle_packet(); + if (auto result = handle_packet(); result.is_error()) { + dbgln("Failed to handle packet: {}", result.error()); + } }; // TODO: Announce on startup. We cannot just call announce() here, // because it races with the network interfaces getting configured. } -void MulticastDNS::handle_packet() +ErrorOr MulticastDNS::handle_packet() { - // TODO: propagate the error somehow - auto buffer = MUST(receive(1024)); + auto buffer = TRY(receive(1024)); auto optional_packet = Packet::from_raw_packet(buffer.data(), buffer.size()); if (!optional_packet.has_value()) { dbgln("Got an invalid mDNS packet"); - return; + return {}; } auto& packet = optional_packet.value(); if (packet.is_query()) handle_query(packet); + return {}; } void MulticastDNS::handle_query(Packet const& packet) diff --git a/Userland/Services/LookupServer/MulticastDNS.h b/Userland/Services/LookupServer/MulticastDNS.h index 4ccba4865d..dab0e0bdbb 100644 --- a/Userland/Services/LookupServer/MulticastDNS.h +++ b/Userland/Services/LookupServer/MulticastDNS.h @@ -29,7 +29,7 @@ private: void announce(); ErrorOr emit_packet(Packet const&, sockaddr_in const* destination = nullptr); - void handle_packet(); + ErrorOr handle_packet(); void handle_query(Packet const&); Vector local_addresses() const;