Browse Source

[PATCH] Make pyVault::AddChronicleEntry a blocking operation to avoid

H-uru:
From f45679a54f Mon Sep 17 00:00:00 2001
From: Adam Johnson <AdamJohnso@gmail.com>
Date: Sun, 15 Jan 2012 18:35:05 -0500
Subject: [PATCH] Make pyVault::AddChronicleEntry a blocking operation to avoid
 a race condition
tickets/10/10/3
Adam Johnson 3 years ago committed by rarified
parent
commit
926267c6de
  1. 5
      Sources/Plasma/FeatureLib/pfPython/pyVault.cpp
  2. 32
      Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp
  3. 2
      Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.h

5
Sources/Plasma/FeatureLib/pfPython/pyVault.cpp

@ -365,7 +365,10 @@ void pyVault::AddChronicleEntry( const char * name, UInt32 type, const char * va
wchar * wEntryName = StrDupToUnicode(name);
wchar * wEntryValue = StrDupToUnicode(value);
VaultAddChronicleEntry(wEntryName, type, wEntryValue);
// FIXME: We should ideally not block, but for now, the Python assumes that when
// we return, the chronicle exists and can be found with findChronicleEntry.
// Maybe we should insert a dummy into the tree? (currently hard)
VaultAddChronicleEntryAndWait(wEntryName, type, wEntryValue);
FREE(wEntryName);
FREE(wEntryValue);

32
Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp

@ -3444,38 +3444,6 @@ bool VaultHasChronicleEntry (const wchar entryName[], int entryType) {
return false;
}
//============================================================================
void VaultAddChronicleEntry (const wchar entryName[], int entryType, const wchar entryValue[]) {
// Sometimes we try to create chrons in StartUp.
// This is bad...
if (GetPlayerNode() == nil)
return;
if (RelVaultNode* rvnChrn = VaultFindChronicleEntryIncRef(entryName, entryType)) {
VaultChronicleNode chrnNode(rvnChrn);
chrnNode.SetEntryValue(entryValue);
rvnChrn->DecRef();
} else {
NetVaultNode* templateNode = NEWZERO(NetVaultNode);
templateNode->IncRef();
templateNode->SetNodeType(plVault::kNodeType_Chronicle);
VaultChronicleNode chrnNode(templateNode);
chrnNode.SetEntryName(entryName);
chrnNode.SetEntryType(entryType);
chrnNode.SetEntryValue(entryValue);
VaultCreateNode(templateNode, (FVaultCreateNodeCallback)(_VaultAddChronicleEntryCB), nil, nil);
templateNode->DecRef();
}
}
void _VaultAddChronicleEntryCB(ENetError result, void* state, void * param, RelVaultNode* node) {
if (result == ENetError::kNetSuccess) {
RelVaultNode* rvnFldr = GetChildFolderNode(GetPlayerNode(), plVault::kChronicleFolder, 1);
if (rvnFldr != nil)
VaultAddChildNode(rvnFldr->nodeId, node->nodeId, 0, nil, nil);
}
}
//============================================================================
void VaultAddChronicleEntryAndWait (
const wchar entryName[],

2
Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.h

@ -357,8 +357,6 @@ bool VaultUnregisterVisitAgeAndWait (const plAgeInfoStruct * info);
RelVaultNode * VaultFindChronicleEntryIncRef (const wchar entryName[], int entryType = -1);
bool VaultHasChronicleEntry (const wchar entryName[], int entryType = -1);
// if entry of same name and type already exists, value is updated
void VaultAddChronicleEntry (const wchar entryName[], int entryType, const wchar entryValue[]);
void _VaultAddChronicleEntryCB(ENetError result, void* state, void * param, RelVaultNode* node);
void VaultAddChronicleEntryAndWait (
const wchar entryName[],
int entryType,

Loading…
Cancel
Save