mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:07: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
|
@ -122,7 +122,8 @@ DHCPv4Client::DHCPv4Client(Vector<DeprecatedString> interfaces_with_dhcp_enabled
|
|||
{
|
||||
m_server = Core::UDPServer::construct(this);
|
||||
m_server->on_ready_to_receive = [this] {
|
||||
auto buffer = m_server->receive(sizeof(DHCPv4Packet));
|
||||
// TODO: we need to handle possible errors here somehow
|
||||
auto buffer = MUST(m_server->receive(sizeof(DHCPv4Packet)));
|
||||
dbgln_if(DHCPV4CLIENT_DEBUG, "Received {} bytes", buffer.size());
|
||||
if (buffer.size() < sizeof(DHCPv4Packet) - DHCPV4_OPTION_FIELD_MAX_LENGTH + 1 || buffer.size() > sizeof(DHCPv4Packet)) {
|
||||
dbgln("we expected {}-{} bytes, this is a bad packet", sizeof(DHCPv4Packet) - DHCPV4_OPTION_FIELD_MAX_LENGTH + 1, sizeof(DHCPv4Packet));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue