diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-05-20 03:47:50 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-05-20 03:47:50 +0200 |
commit | dc03b50f41c344821080efbb18dbbabfa3fcf0c4 (patch) | |
tree | 31c562c1af339d69bcf5b4aabb122a053a615cb2 /LibGUI | |
parent | b3a1671f1a7bf667d3d51ded95757cbb455ceeb9 (diff) | |
download | serenity-dc03b50f41c344821080efbb18dbbabfa3fcf0c4.zip |
GEventLoop: Make the WindowServer connection use a blocking socket.
Diffstat (limited to 'LibGUI')
-rw-r--r-- | LibGUI/GEventLoop.cpp | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/LibGUI/GEventLoop.cpp b/LibGUI/GEventLoop.cpp index 7999c88e49..23c2450d89 100644 --- a/LibGUI/GEventLoop.cpp +++ b/LibGUI/GEventLoop.cpp @@ -31,7 +31,7 @@ pid_t GEventLoop::s_server_pid = -1; void GEventLoop::connect_to_server() { ASSERT(s_windowserver_fd == -1); - s_windowserver_fd = socket(AF_LOCAL, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0); + s_windowserver_fd = socket(AF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0); if (s_windowserver_fd < 0) { perror("socket"); ASSERT_NOT_REACHED(); @@ -326,7 +326,7 @@ bool GEventLoop::drain_messages_from_server() { for (;;) { WSAPI_ServerMessage message; - ssize_t nread = read(s_windowserver_fd, &message, sizeof(WSAPI_ServerMessage)); + ssize_t nread = recv(s_windowserver_fd, &message, sizeof(WSAPI_ServerMessage), MSG_DONTWAIT); if (nread < 0) { if (errno == EAGAIN) { return true; @@ -341,16 +341,10 @@ bool GEventLoop::drain_messages_from_server() exit(-1); return false; } - assert(nread == sizeof(message)); + ASSERT(nread == sizeof(message)); ByteBuffer extra_data; if (message.extra_size) { extra_data = ByteBuffer::create_uninitialized(message.extra_size); - fd_set rfds; - FD_ZERO(&rfds); - FD_SET(s_windowserver_fd, &rfds); - struct timeval timeout { 1, 0 }; - int rc = select(s_windowserver_fd + 1, &rfds, nullptr, nullptr, &timeout); - ASSERT(rc == 1); int extra_nread = read(s_windowserver_fd, extra_data.data(), extra_data.size()); ASSERT(extra_nread == message.extra_size); } |