From 7a4dd4cdf26192659e5312348c18fd5858e7766d Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Mon, 20 Feb 2017 20:08:52 +0100 Subject: Fix epoll wakeup * fibers/epoll.scm (epoll): Like a complete idiot, I broke epoll wakeup. Fixed by calling expiry->timeout while epoll-state is waiting. --- fibers/epoll.scm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/fibers/epoll.scm b/fibers/epoll.scm index 55d88a3..d26db4d 100644 --- a/fibers/epoll.scm +++ b/fibers/epoll.scm @@ -164,12 +164,14 @@ epoll wait (if appropriate)." (let* ((maxevents (epoll-maxevents epoll)) (eventsv (ensure-epoll-eventsv epoll maxevents)) (write-pipe-fd (fileno (epoll-wake-write-pipe epoll))) - (read-pipe-fd (fileno (epoll-wake-read-pipe epoll))) - (timeout (expiry->timeout (update-expiry expiry)))) + (read-pipe-fd (fileno (epoll-wake-read-pipe epoll)))) (atomic-box-set! (epoll-state epoll) 'waiting) - (let ((n (primitive-epoll-wait (epoll-fd epoll) - write-pipe-fd read-pipe-fd - eventsv timeout))) + ;; Note: update-expiry call must take place after epoll-state is + ;; set to waiting. + (let* ((timeout (expiry->timeout (update-expiry expiry))) + (n (primitive-epoll-wait (epoll-fd epoll) + write-pipe-fd read-pipe-fd + eventsv timeout))) (atomic-box-set! (epoll-state epoll) 'not-waiting) ;; If we received `maxevents' events, it means that probably there ;; are more active fd's in the queue that we were unable to -- cgit v1.2.3