1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 23:38:12 +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

@ -18,7 +18,7 @@ namespace Kernel {
class TCPSocket final : public IPv4Socket {
public:
static void for_each(Function<void(const TCPSocket&)>);
static KResultOr<NonnullRefPtr<TCPSocket>> create(int protocol);
static KResultOr<NonnullRefPtr<TCPSocket>> create(int protocol, NonnullOwnPtr<DoubleBuffer> receive_buffer);
virtual ~TCPSocket() override;
enum class Direction {
@ -165,7 +165,7 @@ protected:
void set_direction(Direction direction) { m_direction = direction; }
private:
explicit TCPSocket(int protocol);
explicit TCPSocket(int protocol, NonnullOwnPtr<DoubleBuffer> receive_buffer);
virtual StringView class_name() const override { return "TCPSocket"; }
virtual void shut_down_for_writing() override;