Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Possible unexpected blocking behavior? #3

Closed
dovahcrow opened this issue Oct 11, 2022 · 3 comments
Closed

Possible unexpected blocking behavior? #3

dovahcrow opened this issue Oct 11, 2022 · 3 comments

Comments

@dovahcrow
Copy link
Contributor

The eventfds are only read in the block* method on the sender and receiver. It seems possible that writing to these eventfd will block if they are never read, once the counter in the eventfd reaches maximum

A write(2) call adds the 8-byte integer value supplied in
its buffer to the counter. The maximum value that may be
stored in the counter is the largest unsigned 64-bit value
minus 1 (i.e., 0xfffffffffffffffe). If the addition would
cause the counter's value to exceed the maximum, then the
write(2) either blocks until a read(2) is performed on the
file descriptor, or fails with the error EAGAIN if the
file descriptor has been made nonblocking.

@diwic
Copy link
Owner

diwic commented Oct 11, 2022

In theory I think you're right. But do you see a practical scenario where this could actually happen, or is it a theoretical issue only? Not only because of the 2^64 times you have to write without reading, but also because both sides would either use the blocking function provided, or register the fd with an event loop for all practical cases, right?

@diwic
Copy link
Owner

diwic commented Oct 11, 2022

So, according to the benchmark we're able to send approx 10 packets per microseconds, and 2^64 / 10000000 / 86400 / 365 = 58000 years before it overflows :-) So seems like a theoretical problem to me.

That said I don't mind fixing it if you have a good solution for it? Or just write a comment that this is a problem that exists in theory.

@dovahcrow
Copy link
Contributor Author

if both sides use an event loop, they can still not read it. But I agree that 2^64 is large enough. This question just came to my mind when learning how shmem-ipc works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants