Skip to content

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