1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 10:57:35 +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) void WSMessageLoop::post_message(WSMessageReceiver& receiver, OwnPtr<WSMessage>&& message)
{ {
#ifdef WSMESSAGELOOP_DEBUG #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 #endif
m_queued_messages.append({ receiver.make_weak_ptr(), move(message) }); m_queued_messages.append({ receiver.make_weak_ptr(), move(message) });
} }
@ -169,12 +169,12 @@ void WSMessageLoop::wait_for_message()
sockaddr_un address; sockaddr_un address;
socklen_t address_size = sizeof(address); socklen_t address_size = sizeof(address);
int client_fd = accept(m_server_fd, (sockaddr*)&address, &address_size); int client_fd = accept(m_server_fd, (sockaddr*)&address, &address_size);
#ifdef WSMESSAGELOOP_DEBUG if (client_fd < 0) {
dbgprintf("accept() returned fd=%d, address=%s\n", client_fd, address.sun_path); dbgprintf("WindowServer: accept() failed: %s\n", strerror(errno));
#endif } else {
ASSERT(client_fd >= 0);
new WSClientConnection(client_fd); new WSClientConnection(client_fd);
} }
}
WSClientConnection::for_each_client([&] (WSClientConnection& client) { WSClientConnection::for_each_client([&] (WSClientConnection& client) {
if (!FD_ISSET(client.fd(), &rfds)) if (!FD_ISSET(client.fd(), &rfds))
return; return;