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 race condition with deferred connections #12

Merged
merged 1 commit into from
Jun 28, 2024

Conversation

MiKom
Copy link
Member

@MiKom MiKom commented Jun 28, 2024

Lazy creation of ConnectionEvaluator in event loop was not guarded and
it may happen from a secondary thread (or multiple of those as was the
case with tests). This is actually quite probable as the idea behind
deferred connections is that they may be connected to from threads other
than main.

In "Multiple Signals with Evaluator" test two threads tried to do a deferred
connection at the same time and apparently this caused race condition in
creation of the evaluator.

Now we unconditionally create the connection evaluator in the event
loop. This way, we know that the evaluator is fully created by the end
of the event loop construction. Our assumption is that the user shouldn't
use the evaluator from another thread before the loop is fully
constructed.

@MiKom MiKom requested a review from phyBrackets June 28, 2024 11:41
@MiKom MiKom self-assigned this Jun 28, 2024
@MiKom MiKom force-pushed the fix-connection-evalutor branch from 7ac1c49 to fec12d4 Compare June 28, 2024 14:47
Lazy creation of ConnectionEvaluator in event loop was not guarded and
it may happen from a secondary thread (or multiple of those as was the
case with tests). This is actually quite probable as the idea behind
deferred connections is that they may be connected to from threads other
than main.

In "Multiple Signals with Evaluator" test two threads tried to do a
deferred connection at the same time and apparently this caused race
condition in creation of the evaluator.

Now we unconditionally create the connection evaluator in the event
loop. This way, we know that the evaluator is fully created by the end
of the event loop construction. Our assumption is that user shouldn't
use the evaluator from another thread before the loop is fully
constructed.
Copy link
Contributor

@phyBrackets phyBrackets left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @MiKom for the heads up!

@MiKom MiKom merged commit 17e1c1a into KDAB:main Jun 28, 2024
12 checks passed
@MiKom MiKom deleted the fix-connection-evalutor branch June 28, 2024 14:56
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