1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 09:58:14 +00:00

Kernel: Handle OOM from DoubleBuffer usage in Net/LocalSocket

LocalSockets keep a DoubleBuffer for both client and server usage.
This change converts the usage from using the default constructor
which is unable to observe OOM, to the new try_create factory and
plumb the result through the constructor.
This commit is contained in:
Brian Gianforcaro 2021-08-01 02:34:10 -07:00 committed by Andreas Kling
parent 8d3b819daf
commit 109c885585
2 changed files with 27 additions and 18 deletions

View file

@ -51,7 +51,7 @@ public:
virtual KResult chmod(FileDescription&, mode_t) override;
private:
explicit LocalSocket(int type);
explicit LocalSocket(int type, NonnullOwnPtr<DoubleBuffer> client_buffer, NonnullOwnPtr<DoubleBuffer> server_buffer);
virtual StringView class_name() const override { return "LocalSocket"; }
virtual bool is_local() const override { return true; }
bool has_attached_peer(const FileDescription&) const;
@ -93,8 +93,8 @@ private:
bool m_accept_side_fd_open { false };
sockaddr_un m_address { 0, { 0 } };
DoubleBuffer m_for_client;
DoubleBuffer m_for_server;
NonnullOwnPtr<DoubleBuffer> m_for_client;
NonnullOwnPtr<DoubleBuffer> m_for_server;
NonnullRefPtrVector<FileDescription> m_fds_for_client;
NonnullRefPtrVector<FileDescription> m_fds_for_server;