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

scraper: Move lock on cs_mapParts in RecvManifest #2370

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/gridcoin/scraper/scraper_net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -691,8 +691,6 @@ bool CScraperManifest::RecvManifest(CNode* pfrom, CDataStream& vRecv)

CScraperManifest_shared_ptr manifest = std::shared_ptr<CScraperManifest>(new CScraperManifest());

LOCK(cs_mapParts);

const auto it = mapManifest.emplace(hash, manifest);

{
Expand Down Expand Up @@ -739,8 +737,8 @@ bool CScraperManifest::RecvManifest(CNode* pfrom, CDataStream& vRecv)
ConvergedScraperStatsCache.bClean = false;
}

// Relock manifest
LOCK(manifest->cs_manifest);
// Lock mapParts and relock manifest
LOCK2(cs_mapParts, manifest->cs_manifest);

LogPrint(BCLog::LogFlags::MANIFEST, "received manifest %s with %u / %u parts", hash.GetHex(),
(unsigned) manifest->cntPartsRcvd, (unsigned) manifest->vParts.size());
Expand All @@ -759,6 +757,7 @@ bool CScraperManifest::RecvManifest(CNode* pfrom, CDataStream& vRecv)
// parts, and receipt of parts otherwise.
if (manifest->IsManifestCurrent()) manifest->UseAsSource(pfrom);
}

return true;
}

Expand Down