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

Fixed race condition in MessageFilter using a reader-writer locked reference #383

Closed
wants to merge 1 commit into from

Conversation

StefanFabian
Copy link

@StefanFabian StefanFabian commented May 22, 2019

This pull request fixes issue #379 using a struct that wraps the reference to the class using a reader-writer lock.
The callbacks request shared access to the mutex and can access the filter simultaneously whereas if the filter gets destroyed, the destructor requests unique access and therefore no callback can be executed while the destructor voids the reference.
Once the callback gets access to the reference, it checks if the reference was voided and simply returns Success if it was.

This pull request is an alternative to #384.
Cons:

  • More complicated and has a slight overhead due to locking

Pros:

  • Unless I've made a mistake it is definitely threadsafe and 100% fixes the issue.

The callback is sometimes called after the corresponding MessageFilter instance was destroyed.
This commit fixes this race condition by using a reference that is wrapped using a reader-writer lock.
@rhaschke
Copy link
Contributor

#379 was fixed via #402. This PR can be closed.

@rhaschke rhaschke mentioned this pull request Aug 17, 2019
@StefanFabian
Copy link
Author

Thank you!

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.

2 participants