Skip to content

Commit 7f4b5f8

Browse files
committed
modify:get all information function for download session
1 parent 3c8786b commit 7f4b5f8

File tree

4 files changed

+27
-28
lines changed

4 files changed

+27
-28
lines changed

XEngine_Source/StorageModule_Session/Session_Define.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ typedef struct
3131
__int64x ullRWLen; //已经读取(写入)的大小
3232
__int64x ullPosStart; //开始位置
3333
__int64x ullPosEnd; //结束位置
34+
int nPoolIndex; //任务池索引
3435
FILE* pSt_File;
3536
}SESSION_STORAGEINFO;
3637
//////////////////////////////////////////////////////////////////////////
@@ -259,18 +260,13 @@ extern "C" BOOL Session_DLStroage_GetCount(int nPool, list<string>*pStl_ListClie
259260
extern "C" BOOL Session_DLStorage_SetSeek(LPCTSTR lpszClientAddr, int nSeek, BOOL bError = TRUE, SESSION_STORAGEDYNAMICRATE * pSt_StorageRate = NULL);
260261
/********************************************************************
261262
函数名称:Session_DLStorage_GetAll
262-
函数功能:获取指定下载池的任务列表
263-
参数.一:nPool
264-
In/Out:In
265-
类型:整数型
266-
可空:N
267-
意思:输入要获取的任务池ID
268-
参数.二:pppSt_StorageInfo
263+
函数功能:获取下载池的任务列表
264+
参数.一:pppSt_StorageInfo
269265
In/Out:Out
270266
类型:三级指针
271267
可空:N
272268
意思:输出获取到的下载信息列表
273-
参数.:pInt_ListCount
269+
参数.:pInt_ListCount
274270
In/Out:Out
275271
类型:整数型指针
276272
可空:N
@@ -280,7 +276,7 @@ extern "C" BOOL Session_DLStorage_SetSeek(LPCTSTR lpszClientAddr, int nSeek, BOO
280276
意思:是否成功
281277
备注:
282278
*********************************************************************/
283-
extern "C" BOOL Session_DLStorage_GetAll(int nPool, SESSION_STORAGEINFO*** pppSt_StorageInfo, int* pInt_ListCount);
279+
extern "C" BOOL Session_DLStorage_GetAll(SESSION_STORAGEINFO*** pppSt_StorageInfo, int* pInt_ListCount);
284280
/********************************************************************
285281
函数名称:Session_DLStroage_Delete
286282
函数功能:删除一个队列

XEngine_Source/StorageModule_Session/Session_Stroage/Session_DLStroage.cpp

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ BOOL CSession_DLStroage::Session_DLStroage_Insert(LPCTSTR lpszClientAddr, LPCTST
231231
}
232232
stl_MapIterator = stl_MapStroage.find(nListPos);
233233
stl_MapIterator->second.st_Locker->lock();
234+
st_Client.nPoolIndex = nListPos;
234235
stl_MapIterator->second.pStl_ListStorage->push_back(st_Client);
235236
stl_MapIterator->second.st_Locker->unlock();
236237
st_Locker.unlock();
@@ -529,18 +530,13 @@ BOOL CSession_DLStroage::Session_DLStorage_SetSeek(LPCTSTR lpszClientAddr, int n
529530
}
530531
/********************************************************************
531532
函数名称:Session_DLStorage_GetAll
532-
函数功能:获取指定下载池的任务列表
533-
参数.一:nPool
534-
In/Out:In
535-
类型:整数型
536-
可空:N
537-
意思:输入要获取的任务池ID
538-
参数.二:pppSt_StorageInfo
533+
函数功能:获取下载池的任务列表
534+
参数.一:pppSt_StorageInfo
539535
In/Out:Out
540536
类型:三级指针
541537
可空:N
542538
意思:输出获取到的下载信息列表
543-
参数.:pInt_ListCount
539+
参数.:pInt_ListCount
544540
In/Out:Out
545541
类型:整数型指针
546542
可空:N
@@ -550,7 +546,7 @@ BOOL CSession_DLStroage::Session_DLStorage_SetSeek(LPCTSTR lpszClientAddr, int n
550546
意思:是否成功
551547
备注:
552548
*********************************************************************/
553-
BOOL CSession_DLStroage::Session_DLStorage_GetAll(int nPool, SESSION_STORAGEINFO*** pppSt_StorageInfo, int* pInt_ListCount)
549+
BOOL CSession_DLStroage::Session_DLStorage_GetAll(SESSION_STORAGEINFO*** pppSt_StorageInfo, int* pInt_ListCount)
554550
{
555551
Session_IsErrorOccur = FALSE;
556552

@@ -561,19 +557,26 @@ BOOL CSession_DLStroage::Session_DLStorage_GetAll(int nPool, SESSION_STORAGEINFO
561557
return FALSE;
562558
}
563559

564-
BOOL bFound = FALSE;
560+
int nIndex = 0;
561+
int nListCount = 0;
565562
st_Locker.lock_shared();
566-
unordered_map<int, SESSION_STORAGELIST>::iterator stl_MapIterator = stl_MapStroage.find(nPool);
567-
if (stl_MapIterator != stl_MapStroage.end())
563+
unordered_map<int, SESSION_STORAGELIST>::iterator stl_MapIterator = stl_MapStroage.begin();
564+
for (; stl_MapIterator != stl_MapStroage.end(); stl_MapIterator++)
565+
{
566+
nListCount += stl_MapIterator->second.pStl_ListStorage->size();
567+
}
568+
stl_MapIterator = stl_MapStroage.begin();
569+
for (; stl_MapIterator != stl_MapStroage.end(); stl_MapIterator++)
568570
{
569-
*pInt_ListCount = stl_MapIterator->second.pStl_ListStorage->size();
570-
BaseLib_OperatorMemory_Malloc((XPPPMEM)pppSt_StorageInfo, *pInt_ListCount, sizeof(SESSION_STORAGELIST));
571+
*pInt_ListCount = nListCount;
572+
BaseLib_OperatorMemory_Malloc((XPPPMEM)pppSt_StorageInfo, nListCount, sizeof(SESSION_STORAGELIST));
571573

572574
stl_MapIterator->second.st_Locker->lock_shared();
573575
list<SESSION_STORAGEINFO>::iterator stl_ListIterator = stl_MapIterator->second.pStl_ListStorage->begin();
574-
for (int i = 0; stl_ListIterator != stl_MapIterator->second.pStl_ListStorage->end(); stl_ListIterator++, i++)
576+
for (; stl_ListIterator != stl_MapIterator->second.pStl_ListStorage->end(); stl_ListIterator++)
575577
{
576-
*(*pppSt_StorageInfo)[i] = *stl_ListIterator;
578+
*(*pppSt_StorageInfo)[nIndex] = *stl_ListIterator;
579+
nIndex++;
577580
}
578581
stl_MapIterator->second.st_Locker->unlock_shared();
579582
}

XEngine_Source/StorageModule_Session/Session_Stroage/Session_DLStroage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class CSession_DLStroage
3131
BOOL Session_DLStroage_GetInfo(int nPool, LPCTSTR lpszClientAddr, SESSION_STORAGEINFO* pSt_StorageInfo);
3232
BOOL Session_DLStroage_GetCount(int nPool, list<string>* pStl_ListClient);
3333
BOOL Session_DLStorage_SetSeek(LPCTSTR lpszClientAddr, int nSeek, BOOL bError = TRUE, SESSION_STORAGEDYNAMICRATE* pSt_StorageRate = NULL);
34-
BOOL Session_DLStorage_GetAll(int nPool, SESSION_STORAGEINFO*** pppSt_StorageInfo, int* pInt_ListCount);
34+
BOOL Session_DLStorage_GetAll(SESSION_STORAGEINFO*** pppSt_StorageInfo, int* pInt_ListCount);
3535
BOOL Session_DLStroage_Delete(LPCTSTR lpszClientAddr);
3636
private:
3737
int m_nTryTime;

XEngine_Source/StorageModule_Session/pch.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ extern "C" BOOL Session_DLStorage_SetSeek(LPCTSTR lpszClientAddr, int nSeek, BOO
7676
{
7777
return m_DLStorage.Session_DLStorage_SetSeek(lpszClientAddr, nSeek, bError, pSt_StorageRate);
7878
}
79-
extern "C" BOOL Session_DLStorage_GetAll(int nPool, SESSION_STORAGEINFO * **pppSt_StorageInfo, int* pInt_ListCount)
79+
extern "C" BOOL Session_DLStorage_GetAll(SESSION_STORAGEINFO * **pppSt_StorageInfo, int* pInt_ListCount)
8080
{
81-
return m_DLStorage.Session_DLStorage_GetAll(nPool, pppSt_StorageInfo, pInt_ListCount);
81+
return m_DLStorage.Session_DLStorage_GetAll(pppSt_StorageInfo, pInt_ListCount);
8282
}
8383
extern "C" BOOL Session_DLStroage_Delete(LPCTSTR lpszClientAddr)
8484
{

0 commit comments

Comments
 (0)