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

Fix potential deadlock in the executor #189

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

honzuki
Copy link

@honzuki honzuki commented Jan 31, 2023

spawn and wake are using a version of the send function that "will block until space in the internal buffer becomes available".

That means that if the channel is full, and we try to spawn a new task or a call to wake() was made, send will block the thread, the executor will never get the opportunity to free space in the channel's buffer, and the thread will be stuck in a deadlock.

By using try_send, instead of send, the call will return immediately if the channel's buffer is full, and the call to expect will panic, as expected.

Remove the usage of blocking api inside 'spawn' and 'wake'
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