Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

libbpf-rs: Add wrapper for ringbuffer__epoll_fd #254

Merged
merged 1 commit into from
Jul 28, 2022

Conversation

insearchoflosttime
Copy link
Collaborator

As part of the initiative to reach feature-parity with libbpf-1.0, this
commit adds a wrapper for the ringbuffer__epoll_fd API.

@@ -146,6 +146,15 @@ impl<'a> RingBuffer<'a> {

util::parse_ret(ret)
}

/// Get an fd that can be used to sleep until data is available
pub fn epoll_fd(&self) -> Result<()> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be returning an FD?

And does it need a Result wrapper? Doesn't the RingBuffer hold the invariant that the underlying struct ring_buffer is valid?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fd may be an error value if it failed to create the epoll instance (https://elixir.bootlin.com/linux/latest/source/tools/lib/bpf/ringbuf.c#L177)

Copy link
Collaborator Author

@insearchoflosttime insearchoflosttime Jul 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nvm, just realized that epoll_fd will be called only when fd is valid. I'll update this commit :) thanks for catching this!

As part of the initiative to reach feature-parity with libbpf-1.0, this
commit adds a wrapper for the ringbuffer__epoll_fd API.
@insearchoflosttime insearchoflosttime merged commit 2812a64 into master Jul 28, 2022
@insearchoflosttime insearchoflosttime deleted the ringbuf_epoll_fd branch July 28, 2022 18:39
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants