summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-01-25 10:19:53 +0100
committerAndreas Kling <kling@serenityos.org>2020-01-25 10:34:32 +0100
commit74829cdb753086323fef867cdd1469adfd7ee431 (patch)
tree87f249da8928ab3dfb23479fa1e53896be2c33f2 /Libraries
parente576c9e952f5ad49ec3a2021d1aacbbb45cb6c36 (diff)
downloadserenity-74829cdb753086323fef867cdd1469adfd7ee431.zip
LibIPC: Short-cirtcuit post_message() if socket already disconnected
To allow for more asynchronous teardown of IClientConnection, make the post_message() function simply return if called after the IPC socket has been closed.
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibIPC/IClientConnection.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/Libraries/LibIPC/IClientConnection.h b/Libraries/LibIPC/IClientConnection.h
index 89570fd6ae..e20219cbbb 100644
--- a/Libraries/LibIPC/IClientConnection.h
+++ b/Libraries/LibIPC/IClientConnection.h
@@ -98,6 +98,11 @@ public:
void post_message(const IMessage& message)
{
+ // NOTE: If this connection is being shut down, but has not yet been destroyed,
+ // the socket will be closed. Don't try to send more messages.
+ if (!m_socket->is_open())
+ return;
+
auto buffer = message.encode();
int nwritten = write(m_socket->fd(), buffer.data(), (size_t)buffer.size());