libbpf-rs icon indicating copy to clipboard operation
libbpf-rs copied to clipboard

ringbuf: Allow poll() to block for an indefinite time period

Open insearchoflosttime opened this issue 3 years ago • 2 comments

ring_buffer__poll in libbpf internally calls epoll_wait. Specifying a timeout of -1 to epoll_wait causes it to block indefinitely if no event transpires. We should support this functionality in libbpf-rs as well.

Currently in libbpf-rs, ringbuf's poll only takes in a Duration for the timeout, which therefore cannot be negative. In this change, poll is modified to take in an Option. If the user passes in None for the timeout, then this means that poll() should block indefinitely until an event occurs.

Signed-off-by: Joanne Koong [email protected]

insearchoflosttime avatar Jun 02 '22 23:06 insearchoflosttime

An alternative would be to introduce a new function like epoll_indefinite

insearchoflosttime avatar Jun 04 '22 01:06 insearchoflosttime

Couldn't you check if the value is Duration::MAX and pass -1 if it is? Not sure we need an API break for this

danobi avatar Jul 09 '22 04:07 danobi

Couldn't you check if the value is Duration::MAX and pass -1 if it is? Not sure we need an API break for this

@insearchoflosttime did you get a chance to try @danobi's suggestion with Duration::MAX ?

anakryiko avatar Nov 23 '22 19:11 anakryiko

@anakryiko yes! I will rebase and push it out today.

insearchoflosttime avatar Nov 23 '22 22:11 insearchoflosttime