1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 03:37:45 +00:00

WindowServer: Don't crash when accept() fails, just log an error.

This was easy to hit by opening enough windows to hit the max open file
descriptors limit. :^)
This commit is contained in:
Andreas Kling 2019-03-20 02:31:31 +01:00
parent a02c945ef2
commit 31d3616027

View file

@ -75,7 +75,7 @@ int WSMessageLoop::exec()
void WSMessageLoop::post_message(WSMessageReceiver& receiver, OwnPtr<WSMessage>&& message)
{
#ifdef WSMESSAGELOOP_DEBUG
dbgprintf("WSMessageLoop::post_message: {%u} << receiver=%p, message=%p (type=%u)\n", m_queued_messages.size(), receiver, message.ptr(), message->type());
dbgprintf("WSMessageLoop::post_message: {%u} << receiver=%p, message=%p (type=%u)\n", m_queued_messages.size(), &receiver, message.ptr(), message->type());
#endif
m_queued_messages.append({ receiver.make_weak_ptr(), move(message) });
}
@ -169,12 +169,12 @@ void WSMessageLoop::wait_for_message()
sockaddr_un address;
socklen_t address_size = sizeof(address);
int client_fd = accept(m_server_fd, (sockaddr*)&address, &address_size);
#ifdef WSMESSAGELOOP_DEBUG
dbgprintf("accept() returned fd=%d, address=%s\n", client_fd, address.sun_path);
#endif
ASSERT(client_fd >= 0);
if (client_fd < 0) {
dbgprintf("WindowServer: accept() failed: %s\n", strerror(errno));
} else {
new WSClientConnection(client_fd);
}
}
WSClientConnection::for_each_client([&] (WSClientConnection& client) {
if (!FD_ISSET(client.fd(), &rfds))
return;