Avoid accessing pendingContributionVerifications from VerifyPendingContributions while ReceiveMessage is still doing its job (#3782)

This commit is contained in:
UdjinM6 2020-10-28 22:01:29 +03:00
parent 0814e6145d
commit d8f8f174c0
No known key found for this signature in database
GPG Key ID: 83592BD1400D58D9
2 changed files with 9 additions and 1 deletions

View File

@ -260,6 +260,8 @@ bool CDKGSession::PreVerifyMessage(const uint256& hash, const CDKGContribution&
void CDKGSession::ReceiveMessage(const uint256& hash, const CDKGContribution& qc, bool& retBan)
{
LOCK(cs_pending);
CDKGLogger logger(*this, __func__);
retBan = false;
@ -359,6 +361,8 @@ void CDKGSession::ReceiveMessage(const uint256& hash, const CDKGContribution& qc
// See CBLSWorker::VerifyContributionShares for more details.
void CDKGSession::VerifyPendingContributions()
{
AssertLockHeld(cs_pending);
CDKGLogger logger(*this, __func__);
cxxtimer::Timer t1(true);
@ -412,7 +416,10 @@ void CDKGSession::VerifyAndComplain(CDKGPendingMessages& pendingMessages)
return;
}
VerifyPendingContributions();
{
LOCK(cs_pending);
VerifyPendingContributions();
}
CDKGLogger logger(*this, __func__);

View File

@ -277,6 +277,7 @@ private:
std::map<uint256, CDKGJustification> justifications;
std::map<uint256, CDKGPrematureCommitment> prematureCommitments;
mutable CCriticalSection cs_pending;
std::vector<size_t> pendingContributionVerifications;
// filled by ReceivePrematureCommitment and used by FinalizeCommitments