Smithay / calloop

A callback-based Event Loop
MIT License
176 stars 35 forks source link

epoll timeout rounding logic is broken on 0.10.x #142

Closed elinorbgr closed 9 months ago

elinorbgr commented 1 year ago

This is faulty:

https://github.com/Smithay/calloop/blob/e404c80b101df1b866a82ac696e00b2e7bd3844e/src/sys/epoll.rs#L83-L85

Unconditionally adding 1ms to round up is wrong, the 1 should not be added if the duration is already an exact number of ms, especially if the provided duration is 0, which happens either when the user inputted 0 as a timeout, of if there is a timer that has already fired when the method is invoked.

notgull commented 9 months ago

https://github.com/smol-rs/polling/blob/ea5a38a5001c2b472f7eb503eff14ad0fe179d43/src/epoll.rs#L184-L196

polling implements this logic keeping this in consideration. As calloop now uses polling as its backend as of #123 this issue should be fixed.