diff --git a/src/crystal/system/unix/epoll/event_loop.cr b/src/crystal/system/unix/epoll/event_loop.cr index 2e3ffd966b18..6117a8ac2319 100644 --- a/src/crystal/system/unix/epoll/event_loop.cr +++ b/src/crystal/system/unix/epoll/event_loop.cr @@ -77,7 +77,7 @@ class Crystal::Epoll::EventLoop < Crystal::Evented::EventLoop Crystal.trace :evloop, "wait", blocking: blocking ? 1 : 0 - if blocking && (time = @timers.next_ready?) + if blocking && (time = @mutex.synchronize { @timers.next_ready? }) # epoll_wait only has milliseconds precision, so we use a timerfd for # timeout; arm it to the next ready time @timerfd.set(time) @@ -192,7 +192,7 @@ class Crystal::Epoll::EventLoop < Crystal::Evented::EventLoop end # unsafe, yields when there are no more events for fd - private def system_sync(node : Evented::EventQueue::Node) : Nil + private def system_sync(node : Evented::EventQueue::Node, &) : Nil events = 0 events |= LibC::EPOLLIN if node.readers? events |= LibC::EPOLLOUT if node.writers?