mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 21:57:35 +00:00
LibCore: Make UDPServer::receive() return ErrorOr<ByteBuffer>
This is a first step towards handling OOM errors instead of just crashing the program. Now UDPServer's method `receive()` return memory allocation errors explicitly with help of ErrorOr. This removes one FIXME and make a bunch of new ones. :(
This commit is contained in:
parent
9ae9d82a03
commit
767529ebf5
6 changed files with 19 additions and 17 deletions
|
@ -51,7 +51,8 @@ MulticastDNS::MulticastDNS(Object* parent)
|
|||
|
||||
void MulticastDNS::handle_packet()
|
||||
{
|
||||
auto buffer = receive(1024);
|
||||
// TODO: propagate the error somehow
|
||||
auto buffer = MUST(receive(1024));
|
||||
auto optional_packet = Packet::from_raw_packet(buffer.data(), buffer.size());
|
||||
if (!optional_packet.has_value()) {
|
||||
dbgln("Got an invalid mDNS packet");
|
||||
|
@ -167,7 +168,8 @@ Vector<Answer> MulticastDNS::lookup(Name const& name, RecordType record_type)
|
|||
return {};
|
||||
}
|
||||
|
||||
auto buffer = receive(1024);
|
||||
// TODO: propagate the error somehow
|
||||
auto buffer = MUST(receive(1024));
|
||||
if (buffer.is_empty())
|
||||
return {};
|
||||
auto optional_packet = Packet::from_raw_packet(buffer.data(), buffer.size());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue