Skip to content

Commit

Permalink
Merge pull request #2370 from jamescowens/fix_scraper_deadlock
Browse files Browse the repository at this point in the history
scraper: Move lock on cs_mapParts in RecvManifest
  • Loading branch information
jamescowens authored Oct 31, 2021
2 parents fadf99a + d0441d2 commit 2b667f9
Showing 1 changed file with 3 additions and 4 deletions.
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

0 comments on commit 2b667f9

Please sign in to comment.