Browse Source

Prevent deferred link race conditions

tickets/40/40/1
Adam Johnson 3 years ago committed by ZarothYe
parent
commit
e512dd0c68
  1. 49
      Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp

49
Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp

@ -504,24 +504,55 @@ bool plNetLinkingMgr::IProcessVaultNotifyMsg(plVaultNotifyMsg* msg)
return false; return false;
} }
if (cVaultLink != nil) if (cVaultLink != nil) {
{ // Verify that if the Age vault already exists that it matches the requested
// This is something that Cyan does... >.< // deferred link. If it doesn't exist, well, I hope you're happy with the result.
// It's very useful though...
VaultAgeLinkNode accLink(cVaultLink); VaultAgeLinkNode accLink(cVaultLink);
accLink.CopyTo(cur); if (RelVaultNode* rvnInfo = cVaultLink->GetChildNodeIncRef(plVault::kNodeType_AgeInfo, 1)) {
if (RelVaultNode* rvnInfo = cVaultLink->GetChildNodeIncRef(plVault::kNodeType_AgeInfo, 1)) plAgeInfoStruct dest;
{
VaultAgeInfoNode accInfo(rvnInfo); VaultAgeInfoNode accInfo(rvnInfo);
accInfo.CopyTo(cur->GetAgeInfo()); accInfo.CopyTo(&dest);
if (!dest.IsEqualTo(fDeferredLink->GetAgeLink()->GetAgeInfo())) {
hsLogEntry(
plNetClientMgr::GetInstance()->DebugMsg(
"Waiting for a deferred link to '%s' but got AgeInfo for '%s' instead.",
fDeferredLink->GetAgeLink()->AsStdString().c_str(),
dest.AsStdString().c_str()
);
);
rvnInfo->DecRef(); rvnInfo->DecRef();
return false;
} }
rvnInfo->DecRef();
}
// If we're still here, that means the links match. Set the vault copy as our current
// AgeLink and AgeInfo. Note this mainly copies the AgeInfo.
accLink.CopyTo(cur);
hsLogEntry(
plNetClientMgr::GetInstance()->DebugMsg(
"Performing deferred link to '%s'",
cur->AsStdString().c_str()
);
);
// Steals fDeferredLink
IDoLink(fDeferredLink); IDoLink(fDeferredLink);
fDeferredLink = nil; fDeferredLink = nil;
return true;
cVaultLink->DecRef(); cVaultLink->DecRef();
return true;
} else {
hsLogEntry(
plNetClientMgr::GetInstance()->ErrorMsg(
"Waiting for a deferred link to '%s' but got a garbage link?",
fDeferredLink->GetAgeLink()->AsStdString().c_str()
)
);
} }
return false; return false;

Loading…
Cancel
Save