mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-14 02:27:40 -04:00
[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
This commit is contained in:
@ -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);
|
||||
|
@ -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[],
|
||||
|
@ -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,
|
||||
|
Reference in New Issue
Block a user