diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-07-14 14:28:24 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-07-14 14:28:24 +0200 |
commit | e8d61bb8c0580683fcbc171825c680ef106024d6 (patch) | |
tree | 966911836a86affd297d0b4131a4bf0f5661a13b /Libraries/LibCore/CEventLoop.cpp | |
parent | 4c0c93ce0941c97a079b2f36c654623861b5281e (diff) | |
download | serenity-e8d61bb8c0580683fcbc171825c680ef106024d6.zip |
CEventLoop: Oops, I had the pipe reader/writer fd's mixed up.
Diffstat (limited to 'Libraries/LibCore/CEventLoop.cpp')
-rw-r--r-- | Libraries/LibCore/CEventLoop.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Libraries/LibCore/CEventLoop.cpp b/Libraries/LibCore/CEventLoop.cpp index 88e719d9dd..a2eada598a 100644 --- a/Libraries/LibCore/CEventLoop.cpp +++ b/Libraries/LibCore/CEventLoop.cpp @@ -172,7 +172,7 @@ void CEventLoop::wait_for_event(WaitMode mode) int max_fd_added = -1; add_file_descriptors_for_select(rfds, max_fd_added); - add_fd_to_set(s_wake_pipe_fds[1], rfds); + add_fd_to_set(s_wake_pipe_fds[0], rfds); max_fd = max(max_fd, max_fd_added); for (auto& notifier : *s_notifiers) { if (notifier->event_mask() & CNotifier::Read) @@ -209,9 +209,14 @@ void CEventLoop::wait_for_event(WaitMode mode) ASSERT_NOT_REACHED(); } - if (FD_ISSET(s_wake_pipe_fds[1], &rfds)) { + if (FD_ISSET(s_wake_pipe_fds[0], &rfds)) { char buffer[32]; - read(s_wake_pipe_fds[1], buffer, sizeof(buffer)); + auto nread = read(s_wake_pipe_fds[0], buffer, sizeof(buffer)); + if (nread < 0) { + perror("read from wake pipe"); + ASSERT_NOT_REACHED(); + } + ASSERT(nread > 0); } if (!s_timers->is_empty()) { @@ -314,7 +319,7 @@ void CEventLoop::unregister_notifier(Badge<CNotifier>, CNotifier& notifier) void CEventLoop::wake() { char ch = '!'; - int nwritten = write(s_wake_pipe_fds[0], &ch, 1); + int nwritten = write(s_wake_pipe_fds[1], &ch, 1); if (nwritten < 0) { perror("CEventLoop::wake: write"); ASSERT_NOT_REACHED(); |