1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:57:44 +00:00

Kernel: Handle OOM from DoubleBuffer usage in IPv4Socket

The IPv4Socket requires a DoubleBuffer for storage of any data it
received on the socket. However it was previously using the default
constructor which can not observe allocation failure. Address this by
plumbing the receive buffer through the various derived classes.
This commit is contained in:
Brian Gianforcaro 2021-08-01 02:42:03 -07:00 committed by Andreas Kling
parent 109c885585
commit ca94a83337
6 changed files with 41 additions and 26 deletions

View file

@ -13,14 +13,14 @@ namespace Kernel {
class UDPSocket final : public IPv4Socket {
public:
static KResultOr<NonnullRefPtr<UDPSocket>> create(int protocol);
static KResultOr<NonnullRefPtr<UDPSocket>> create(int protocol, NonnullOwnPtr<DoubleBuffer> receive_buffer);
virtual ~UDPSocket() override;
static SocketHandle<UDPSocket> from_port(u16);
static void for_each(Function<void(const UDPSocket&)>);
private:
explicit UDPSocket(int protocol);
explicit UDPSocket(int protocol, NonnullOwnPtr<DoubleBuffer> receive_buffer);
virtual StringView class_name() const override { return "UDPSocket"; }
static Lockable<HashMap<u16, UDPSocket*>>& sockets_by_port();