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

Only use one thread with Tokio #202

Merged
merged 1 commit into from Jun 4, 2022
Merged

Only use one thread with Tokio #202

merged 1 commit into from Jun 4, 2022

Conversation

asomers
Copy link
Collaborator

@asomers asomers commented Jun 4, 2022

When Tokio gets event notification from kevent, the pending future may
belong to a different thread. If so, it signals the other thread and
pends on kevent again. But the other thread may not have had time to
call aio_return yet. In that case, the first thread's kevent will
immediately return again.

The correct solution is to set EV_ONESHOT on the aiocb. But Rust's libc
doesn't currently expose the necessary field. Until it does, restrict
Tokio to just a single thread.

rust-lang/libc#2813

When Tokio gets event notification from kevent, the pending future may
belong to a different thread.  If so, it signals the other thread and
pends on kevent again.  But the other thread may not have had time to
call aio_return yet.  In that case, the first thread's kevent will
immediately return again.

The correct solution is to set EV_ONESHOT on the aiocb.  But Rust's libc
doesn't currently expose the necessary field.  Until it does, restrict
Tokio to just a single thread.

rust-lang/libc#2813
@asomers asomers merged commit 4a2f106 into master Jun 4, 2022
@asomers asomers deleted the current-thread branch June 4, 2022 02:43
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

Successfully merging this pull request may close these issues.

None yet

1 participant