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

mixpool: Add missing mutex acquire #3296

Merged
merged 1 commit into from
May 18, 2024
Merged

Conversation

jrick
Copy link
Member

@jrick jrick commented May 18, 2024

reconsiderOrphans was accessing pool state without the pool mutex held, which
results in data races.

To resolve this, some refactoring is necessary. reconsiderOrphans calls
acceptKE, which did acquire the mutex, so that needs to be hoisted out.

In this commit, the pre-mutex-acquire sanity checks for PR and KE messages in
acceptPR and acceptKE are moved to separate checkAccept{PR,KE} functions for
the caller, who then becomes responsible for acquiring the mutex. After
acceptPR/acceptKE return, reconsiderOrphans is then called with the mutex
still held.

This is a backport candidate for 2.0.1.

reconsiderOrphans was accessing pool state without the pool mutex held, which
results in data races.

To resolve this, some refactoring is necessary.  reconsiderOrphans calls
acceptKE, which did acquire the mutex, so that needs to be hoisted out.

In this commit, the pre-mutex-acquire sanity checks for PR and KE messages in
acceptPR and acceptKE are moved to separate checkAccept{PR,KE} functions for
the caller, who then becomes responsible for acquiring the mutex.  After
acceptPR/acceptKE return, reconsiderOrphans is then called with the mutex
still held.

This is a backport candidate for 2.0.1.
@davecgh davecgh added this to the 2.0.1 milestone May 18, 2024
@davecgh davecgh merged commit ac51ffa into decred:master May 18, 2024
2 checks passed
@jrick jrick deleted the mixpool_mutex branch May 18, 2024 22:23
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

2 participants