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

Put unhandled responses back on the queue #440

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

Conversation

mjg59
Copy link

@mjg59 mjg59 commented Feb 16, 2021

In a multithreaded environment (such as having a separate thread to wait
for notifications), it's possible that the response for one event (such
as the completion of a write) may be consumed by another thread (such as
one that's just waiting for notifications). If the write response is never
delivered to the correct thread, it will block - and if there are no
timeouts, it will deadlock.

This approach simply makes the assumption that if an unhandled event shows
up, it was probably intended for another thread - simply putting it back
on the queue will allow that other thread to have a go at parsing it. In
the event of a genuinely unexpected message this will result in a lot of
busy work and the event never being cleared, which isn't ideal. I'm not
sure if there's a more reasonable approach to this.

@mjg59
Copy link
Author

mjg59 commented Feb 16, 2021

I think this should fix #349

In a multithreaded environment (such as having a separate thread to wait
for notifications), it's possible that the response for one event (such
as the completion of a write) may be consumed by another thread (such as
one that's just waiting for notifications). If the write response is never
delivered to the correct thread, it will block - and if there are no
timeouts, it will deadlock.

This approach simply makes the assumption that if an unhandled event shows
up, it was probably intended for another thread - simply putting it back
on the queue will allow that other thread to have a go at parsing it. In
the event of a genuinely unexpected message this will result in a lot of
busy work and the event never being cleared, which isn't ideal. I'm not
sure if there's a more reasonable approach to this.
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.

1 participant