decred / dcrd

Decred daemon in Go (golang).
https://decred.org
ISC License
738 stars 291 forks source link

mixpool: Add missing mutex acquire #3296

Closed jrick closed 5 months ago

jrick commented 5 months ago

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.