From 427df5f312bda5f8655e2a1124c16dbb0dcd01d9 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 14 Feb 2019 10:06:41 +0100 Subject: [PATCH] LibGUI: Yield (using select()) in GEventLoop::wait_for_specific_event(). This is factored a bit stupidly. It would be nicer to just have the read() in drain_events_from_server() be blocking, but the fd is opened with O_NONBLOCK right now. This makes everything run real snappy once again. :^) --- LibGUI/GEventLoop.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/LibGUI/GEventLoop.cpp b/LibGUI/GEventLoop.cpp index f2e279d1a75..f7dfe73555b 100644 --- a/LibGUI/GEventLoop.cpp +++ b/LibGUI/GEventLoop.cpp @@ -365,6 +365,12 @@ bool GEventLoop::post_message_to_server(const GUI_ClientMessage& message) bool GEventLoop::wait_for_specific_event(GUI_ServerMessage::Type type, GUI_ServerMessage& event) { for (;;) { + fd_set rfds; + FD_ZERO(&rfds); + FD_SET(m_event_fd, &rfds); + int rc = select(m_event_fd + 1, &rfds, nullptr, nullptr, nullptr); + ASSERT(rc > 0); + ASSERT(FD_ISSET(m_event_fd, &rfds)); bool success = drain_messages_from_server(); if (!success) return false;