From 5f597d0cb269b237985a5fec314c2621480120ad Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Sun, 19 May 2019 10:26:06 +0200 Subject: [PATCH] WindowServer: Improve client write handling a little * EPIPE now correctly deletes the client connection * EAGAIN (which is now returned by the kernel if the write buffer fills) terminates the connection also --- Servers/WindowServer/WSClientConnection.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Servers/WindowServer/WSClientConnection.cpp b/Servers/WindowServer/WSClientConnection.cpp index 6f3a3da9aa..b9a85f6902 100644 --- a/Servers/WindowServer/WSClientConnection.cpp +++ b/Servers/WindowServer/WSClientConnection.cpp @@ -92,12 +92,21 @@ void WSClientConnection::post_message(const WSAPI_ServerMessage& message, const int nwritten = writev(m_fd, iov, iov_count); if (nwritten < 0) { - if (errno == EPIPE) { + switch (errno) { + case EPIPE: dbgprintf("WSClientConnection::post_message: Disconnected from peer.\n"); + delete_later(); return; + break; + case EAGAIN: + dbgprintf("WSClientConnection::post_message: Client buffer overflowed.\n"); + did_misbehave(); + return; + break; + default: + perror("WSClientConnection::post_message writev"); + ASSERT_NOT_REACHED(); } - perror("WSClientConnection::post_message writev"); - ASSERT_NOT_REACHED(); } ASSERT(nwritten == sizeof(message) + extra_data.size());