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.
This commit is contained in:
Andreas Kling 2020-01-25 10:19:53 +01:00
parent e576c9e952
commit 74829cdb75
Notes: sideshowbarker 2024-07-19 09:50:37 +09:00

View File

@ -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());