1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 01:17:34 +00:00

LibIPC: Fix server crashes on client disconnects

The server should always survive client communication errors.
This commit is contained in:
Sergey Bugaev 2020-05-30 22:37:24 +03:00 committed by Andreas Kling
parent 4aa3d08e21
commit 8449f0a15b

View file

@ -121,7 +121,8 @@ public:
return; return;
default: default:
perror("Connection::post_message write"); perror("Connection::post_message write");
ASSERT_NOT_REACHED(); shutdown();
return;
} }
} }
@ -130,6 +131,9 @@ public:
void drain_messages_from_client() void drain_messages_from_client()
{ {
if (!m_socket->is_open())
return;
Vector<u8> bytes; Vector<u8> bytes;
for (;;) { for (;;) {
u8 buffer[4096]; u8 buffer[4096];
@ -143,7 +147,8 @@ public:
} }
if (nread < 0) { if (nread < 0) {
perror("recv"); perror("recv");
ASSERT_NOT_REACHED(); shutdown();
return;
} }
bytes.append(buffer, nread); bytes.append(buffer, nread);
} }