|
|
@ -250,7 +250,7 @@ struct AddChildNodeFetchTrans { |
|
|
|
FVaultAddChildNodeCallback callback; |
|
|
|
FVaultAddChildNodeCallback callback; |
|
|
|
void * cbParam; |
|
|
|
void * cbParam; |
|
|
|
ENetError result; |
|
|
|
ENetError result; |
|
|
|
long opCount; |
|
|
|
std::atomic<long> opCount; |
|
|
|
|
|
|
|
|
|
|
|
AddChildNodeFetchTrans() |
|
|
|
AddChildNodeFetchTrans() |
|
|
|
: callback(nil), cbParam(nil), result(kNetSuccess), opCount(0) { } |
|
|
|
: callback(nil), cbParam(nil), result(kNetSuccess), opCount(0) { } |
|
|
@ -1019,12 +1019,11 @@ void AddChildNodeFetchTrans::VaultNodeRefsFetched ( |
|
|
|
param, |
|
|
|
param, |
|
|
|
&incFetchCount |
|
|
|
&incFetchCount |
|
|
|
); |
|
|
|
); |
|
|
|
AtomicAdd(&trans->opCount, incFetchCount); |
|
|
|
trans->opCount += incFetchCount; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Make the callback now if there are no nodes to fetch, or if error
|
|
|
|
// Make the callback now if there are no nodes to fetch, or if error
|
|
|
|
AtomicAdd(&trans->opCount, -1);
|
|
|
|
if (!(--trans->opCount)) { |
|
|
|
if (!trans->opCount) { |
|
|
|
|
|
|
|
if (trans->callback) |
|
|
|
if (trans->callback) |
|
|
|
trans->callback( |
|
|
|
trans->callback( |
|
|
|
trans->result, |
|
|
|
trans->result, |
|
|
@ -1047,8 +1046,7 @@ void AddChildNodeFetchTrans::VaultNodeFetched ( |
|
|
|
if (IS_NET_ERROR(result)) |
|
|
|
if (IS_NET_ERROR(result)) |
|
|
|
trans->result = result; |
|
|
|
trans->result = result; |
|
|
|
|
|
|
|
|
|
|
|
AtomicAdd(&trans->opCount, -1);
|
|
|
|
if (!(--trans->opCount)) { |
|
|
|
if (!trans->opCount) { |
|
|
|
|
|
|
|
if (trans->callback) |
|
|
|
if (trans->callback) |
|
|
|
trans->callback( |
|
|
|
trans->callback( |
|
|
|
trans->result, |
|
|
|
trans->result, |
|
|
@ -1793,13 +1791,13 @@ void VaultAddChildNode ( |
|
|
|
// One or more nodes need to be fetched before the callback is made
|
|
|
|
// One or more nodes need to be fetched before the callback is made
|
|
|
|
AddChildNodeFetchTrans * trans = new AddChildNodeFetchTrans(callback, param); |
|
|
|
AddChildNodeFetchTrans * trans = new AddChildNodeFetchTrans(callback, param); |
|
|
|
if (!childLink->node->GetNodeType()) { |
|
|
|
if (!childLink->node->GetNodeType()) { |
|
|
|
AtomicAdd(&trans->opCount, 1); |
|
|
|
++trans->opCount; |
|
|
|
NetCliAuthVaultNodeFetch( |
|
|
|
NetCliAuthVaultNodeFetch( |
|
|
|
childId, |
|
|
|
childId, |
|
|
|
AddChildNodeFetchTrans::VaultNodeFetched, |
|
|
|
AddChildNodeFetchTrans::VaultNodeFetched, |
|
|
|
trans |
|
|
|
trans |
|
|
|
); |
|
|
|
); |
|
|
|
AtomicAdd(&trans->opCount, 1); |
|
|
|
++trans->opCount; |
|
|
|
NetCliAuthVaultFetchNodeRefs( |
|
|
|
NetCliAuthVaultFetchNodeRefs( |
|
|
|
childId, |
|
|
|
childId, |
|
|
|
AddChildNodeFetchTrans::VaultNodeRefsFetched, |
|
|
|
AddChildNodeFetchTrans::VaultNodeRefsFetched, |
|
|
@ -1807,13 +1805,13 @@ void VaultAddChildNode ( |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!parentLink->node->GetNodeType()) { |
|
|
|
if (!parentLink->node->GetNodeType()) { |
|
|
|
AtomicAdd(&trans->opCount, 1); |
|
|
|
++trans->opCount; |
|
|
|
NetCliAuthVaultNodeFetch( |
|
|
|
NetCliAuthVaultNodeFetch( |
|
|
|
parentId, |
|
|
|
parentId, |
|
|
|
AddChildNodeFetchTrans::VaultNodeFetched, |
|
|
|
AddChildNodeFetchTrans::VaultNodeFetched, |
|
|
|
trans |
|
|
|
trans |
|
|
|
); |
|
|
|
); |
|
|
|
AtomicAdd(&trans->opCount, 1); |
|
|
|
++trans->opCount; |
|
|
|
NetCliAuthVaultFetchNodeRefs( |
|
|
|
NetCliAuthVaultFetchNodeRefs( |
|
|
|
parentId, |
|
|
|
parentId, |
|
|
|
AddChildNodeFetchTrans::VaultNodeRefsFetched, |
|
|
|
AddChildNodeFetchTrans::VaultNodeRefsFetched, |
|
|
@ -2218,8 +2216,7 @@ namespace _VaultFetchNodesAndWait { |
|
|
|
) { |
|
|
|
) { |
|
|
|
::VaultNodeFetched(result, nil, node); |
|
|
|
::VaultNodeFetched(result, nil, node); |
|
|
|
|
|
|
|
|
|
|
|
long * nodeCount = (long *)param; |
|
|
|
--(*reinterpret_cast<std::atomic<unsigned>*>(param)); |
|
|
|
AtomicAdd(nodeCount, -1); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} // namespace _VaultFetchNodesAndWait
|
|
|
|
} // namespace _VaultFetchNodesAndWait
|
|
|
@ -2231,20 +2228,21 @@ void VaultFetchNodesAndWait ( |
|
|
|
) { |
|
|
|
) { |
|
|
|
using namespace _VaultFetchNodesAndWait; |
|
|
|
using namespace _VaultFetchNodesAndWait; |
|
|
|
|
|
|
|
|
|
|
|
long nodeCount = (long)count; |
|
|
|
std::atomic<unsigned> nodeCount(count); |
|
|
|
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < count; ++i) { |
|
|
|
for (unsigned i = 0; i < count; ++i) { |
|
|
|
|
|
|
|
|
|
|
|
if (!force) { |
|
|
|
if (!force) { |
|
|
|
// See if we already have this node
|
|
|
|
// See if we already have this node
|
|
|
|
if (RelVaultNodeLink * link = s_nodes.Find(nodeIds[i])) { |
|
|
|
if (RelVaultNodeLink * link = s_nodes.Find(nodeIds[i])) { |
|
|
|
AtomicAdd(&nodeCount, -1); |
|
|
|
--nodeCount; |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Start fetching the node
|
|
|
|
// Start fetching the node
|
|
|
|
NetCliAuthVaultNodeFetch(nodeIds[i], _VaultNodeFetched, (void *)&nodeCount); |
|
|
|
NetCliAuthVaultNodeFetch(nodeIds[i], _VaultNodeFetched, |
|
|
|
|
|
|
|
reinterpret_cast<void *>(&nodeCount)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
while (nodeCount) { |
|
|
|
while (nodeCount) { |
|
|
|