|
13 | 13 | *********************************************************************/ |
14 | 14 | CAPIHelp_Distributed::CAPIHelp_Distributed() |
15 | 15 | { |
16 | | - |
| 16 | + nRandomFront = 0; |
| 17 | + nRandomBack = 0; |
| 18 | + nUPFront = 0; |
| 19 | + nUPBack = 0; |
17 | 20 | } |
18 | 21 | CAPIHelp_Distributed::~CAPIHelp_Distributed() |
19 | 22 | { |
@@ -78,14 +81,37 @@ BOOL CAPIHelp_Distributed::APIHelp_Distributed_RandomAddr(list<string>* pStl_Lis |
78 | 81 | } |
79 | 82 | else if (2 == nMode) |
80 | 83 | { |
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 | + } |
83 | 98 | } |
84 | 99 | else if (3 == nMode) |
85 | 100 | { |
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 | + } |
89 | 115 | } |
90 | 116 |
|
91 | 117 | if (!bFound) |
@@ -349,11 +375,35 @@ BOOL CAPIHelp_Distributed::APIHelp_Distributed_UPStorage(LPCTSTR lpszMsgBuffer, |
349 | 375 | } |
350 | 376 | else if (2 == nMode) |
351 | 377 | { |
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 | + } |
353 | 391 | } |
354 | 392 | else if (3 == nMode) |
355 | 393 | { |
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 | + } |
357 | 407 | } |
358 | 408 | } |
359 | 409 |
|
|
0 commit comments