Skip to content

Commit 0cfc888

Browse files
committed
fixed:The problem that only one of the distributed redirection 2 and 3 modes will always be selected
1 parent 1b253b7 commit 0cfc888

File tree

2 files changed

+62
-8
lines changed

2 files changed

+62
-8
lines changed

XEngine_Source/StorageModule_APIHelp/APIHelp_Distributed/APIHelp_Distributed.cpp

Lines changed: 58 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
*********************************************************************/
1414
CAPIHelp_Distributed::CAPIHelp_Distributed()
1515
{
16-
16+
nRandomFront = 0;
17+
nRandomBack = 0;
18+
nUPFront = 0;
19+
nUPBack = 0;
1720
}
1821
CAPIHelp_Distributed::~CAPIHelp_Distributed()
1922
{
@@ -78,14 +81,37 @@ BOOL CAPIHelp_Distributed::APIHelp_Distributed_RandomAddr(list<string>* pStl_Lis
7881
}
7982
else if (2 == nMode)
8083
{
81-
bFound = TRUE;
82-
_tcscpy(ptszAddr, pStl_ListAddr->front().c_str());
84+
if (nRandomFront >= pStl_ListAddr->size())
85+
{
86+
nRandomFront = 0;
87+
}
88+
int i = 0;
89+
for (auto stl_ListIterator = pStl_ListAddr->begin(); stl_ListIterator != pStl_ListAddr->end(); stl_ListIterator++, i++)
90+
{
91+
if (nRandomFront == i)
92+
{
93+
bFound = TRUE;
94+
_tcscpy(ptszAddr, stl_ListIterator->c_str());
95+
break;
96+
}
97+
}
8398
}
8499
else if (3 == nMode)
85100
{
86-
87-
bFound = TRUE;
88-
_tcscpy(ptszAddr, pStl_ListAddr->back().c_str());
101+
if (nRandomBack >= pStl_ListAddr->size())
102+
{
103+
nRandomBack = 0;
104+
}
105+
int i = 0;
106+
for (auto stl_ListIterator = pStl_ListAddr->rbegin(); stl_ListIterator != pStl_ListAddr->rend(); stl_ListIterator++, i++)
107+
{
108+
if (nRandomBack == i)
109+
{
110+
bFound = TRUE;
111+
_tcscpy(ptszAddr, stl_ListIterator->c_str());
112+
break;
113+
}
114+
}
89115
}
90116

91117
if (!bFound)
@@ -349,11 +375,35 @@ BOOL CAPIHelp_Distributed::APIHelp_Distributed_UPStorage(LPCTSTR lpszMsgBuffer,
349375
}
350376
else if (2 == nMode)
351377
{
352-
*pSt_StorageBucket = stl_BuckSelect.front();
378+
if (nUPFront >= stl_BuckSelect.size())
379+
{
380+
nUPFront = 0;
381+
}
382+
int i = 0;
383+
for (auto stl_ListIterator = stl_BuckSelect.begin(); stl_ListIterator != stl_BuckSelect.end(); stl_ListIterator++, i++)
384+
{
385+
if (nUPFront == i)
386+
{
387+
*pSt_StorageBucket = *stl_ListIterator;
388+
break;
389+
}
390+
}
353391
}
354392
else if (3 == nMode)
355393
{
356-
*pSt_StorageBucket = stl_BuckSelect.back();
394+
if (nUPFront >= stl_BuckSelect.size())
395+
{
396+
nUPFront = 0;
397+
}
398+
int i = 0;
399+
for (auto stl_ListIterator = stl_BuckSelect.rbegin(); stl_ListIterator != stl_BuckSelect.rend(); stl_ListIterator++, i++)
400+
{
401+
if (nUPFront == i)
402+
{
403+
*pSt_StorageBucket = *stl_ListIterator;
404+
break;
405+
}
406+
}
357407
}
358408
}
359409

XEngine_Source/StorageModule_APIHelp/APIHelp_Distributed/APIHelp_Distributed.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,8 @@ class CAPIHelp_Distributed
2727
BOOL APIHelp_Distributed_FileListParse(LPCTSTR lpszMsgBuffer, int nMsgLen, XSTORAGECORE_DBFILE* pSt_DBFile);
2828
__int64u APIHelp_Distributed_GetSize(LPCTSTR lpszMsgBuffer);
2929
private:
30+
unsigned int nRandomFront;
31+
unsigned int nRandomBack;
32+
unsigned int nUPFront;
33+
unsigned int nUPBack;
3034
};

0 commit comments

Comments
 (0)