@@ -27,23 +27,17 @@ CSession_DLStroage::~CSession_DLStroage()
2727 In/Out:In
2828 类型:整数型
2929 可空:Y
30- 意思:输入重试次数
31- 参数.二:nAutoSpeed
32- In/Out:In
33- 类型:整数型
34- 可空:Y
35- 意思:输入恢复次数,超过次数不在恢复
30+ 意思:输入下载错误重试次数
3631返回值
3732 类型:逻辑型
3833 意思:是否成功
3934备注:
4035*********************************************************************/
41- BOOL CSession_DLStroage::Session_DLStroage_Init (int nTryTime /* = 3 */ , int nAutoSpeed /* = 3 */ )
36+ BOOL CSession_DLStroage::Session_DLStroage_Init (int nTryTime /* = 3 */ )
4237{
4338 Session_IsErrorOccur = FALSE ;
4439
4540 m_nTryTime = nTryTime;
46- m_nTryAuto = nAutoSpeed;
4741 return TRUE ;
4842}
4943/* *******************************************************************
@@ -292,57 +286,18 @@ BOOL CSession_DLStroage::Session_DLStroage_GetInfo(LPCTSTR lpszClientAddr, SESSI
292286 意思:是否成功
293287备注:
294288*********************************************************************/
295- BOOL CSession_DLStroage::Session_DLStroage_GetCount (list<string>* pStl_ListClient )
289+ BOOL CSession_DLStroage::Session_DLStroage_GetCount (int * pInt_ListCount )
296290{
297291 Session_IsErrorOccur = FALSE ;
298292
299- if (NULL == pStl_ListClient )
293+ if (NULL == pInt_ListCount )
300294 {
301295 Session_IsErrorOccur = TRUE ;
302296 Session_dwErrorCode = ERROR_STORAGE_MODULE_SESSION_PARAMENT;
303297 return FALSE ;
304298 }
305-
306299 st_Locker.lock_shared ();
307- unordered_map<tstring, SESSION_STORAGEINFO>::iterator stl_MapIterator = stl_MapStroage.begin ();
308- for (; stl_MapIterator != stl_MapStroage.end (); stl_MapIterator++)
309- {
310- // 是否需要等待恢复
311- if (stl_MapIterator->second .st_DynamicRate .ullTimeWait > 0 )
312- {
313- XENGINE_VALTIME st_TimeVal;
314- time_t nTimeNow = time (NULL );
315-
316- memset (&st_TimeVal, ' \0 ' , sizeof (XENGINE_VALTIME));
317- BaseLib_OperatorTime_GetTimeOfday (&st_TimeVal);
318- if (((st_TimeVal.tv_value - stl_MapIterator->second .st_DynamicRate .ullTimeSend ) > stl_MapIterator->second .st_DynamicRate .ullTimeWait ) && ((nTimeNow - stl_MapIterator->second .st_DynamicRate .nTimeError ) > 1 ))
319- {
320- // 等待时间超过,可以加入
321- pStl_ListClient->push_back (stl_MapIterator->second .tszClientAddr );
322- stl_MapIterator->second .st_DynamicRate .ullTimeSend = st_TimeVal.tv_value ;
323- }
324- // 速率恢复测算
325- if ((stl_MapIterator->second .st_DynamicRate .nAutoNumber <= m_nTryAuto) && ((nTimeNow - stl_MapIterator->second .st_DynamicRate .nTimeError ) > (stl_MapIterator->second .st_DynamicRate .nErrorCount * stl_MapIterator->second .st_DynamicRate .nAutoNumber )))
326- {
327- // printf("nAutoNumber:%d <= m_nTryAuto:%d,nTimeNow:%lu - nTimeError:%lu nErrorCount:%d\n", stl_MapIterator->second.st_DynamicRate.nAutoNumber, m_nTryAuto, nTimeNow, stl_MapIterator->second.st_DynamicRate.nTimeError, stl_MapIterator->second.st_DynamicRate.nErrorCount * stl_MapIterator->second.st_DynamicRate.nAutoNumber);
328- stl_MapIterator->second .st_DynamicRate .nAutoNumber ++;
329- stl_MapIterator->second .st_DynamicRate .nErrorCount --;
330- stl_MapIterator->second .st_DynamicRate .ullTimeWait -= (XENGINE_STOREAGE_SESSION_DOWNLOAD_SENDTIME * stl_MapIterator->second .st_DynamicRate .nTimeError );
331- if (0 == stl_MapIterator->second .st_DynamicRate .nErrorCount )
332- {
333- stl_MapIterator->second .st_DynamicRate .nTimeError = 0 ;
334- }
335- else
336- {
337- stl_MapIterator->second .st_DynamicRate .nTimeError = nTimeNow;
338- }
339- }
340- }
341- else
342- {
343- pStl_ListClient->push_back (stl_MapIterator->second .tszClientAddr );
344- }
345- }
300+ *pInt_ListCount = stl_MapStroage.size ();
346301 st_Locker.unlock_shared ();
347302 return TRUE ;
348303}
@@ -363,18 +318,13 @@ BOOL CSession_DLStroage::Session_DLStroage_GetCount(list<string>* pStl_ListClien
363318 In/Out:In
364319 类型:逻辑型
365320 可空:Y
366- 意思:是否因为错误引起的
367- 参数.四:pSt_StorageRate
368- In/Out:In
369- 类型:数据结构指针
370- 可空:Y
371- 意思:输出速率错误信息
321+ 意思:是否有由错误引起的
372322返回值
373323 类型:逻辑型
374324 意思:是否成功
375325备注:
376326*********************************************************************/
377- BOOL CSession_DLStroage::Session_DLStorage_SetSeek (LPCTSTR lpszClientAddr, int nSeek, BOOL bError /* = TRUE */ , SESSION_STORAGEDYNAMICRATE* pSt_StorageRate /* = NULL */ )
327+ BOOL CSession_DLStroage::Session_DLStorage_SetSeek (LPCTSTR lpszClientAddr, int nSeek, BOOL bError /* = TRUE */ )
378328{
379329 Session_IsErrorOccur = FALSE ;
380330
@@ -387,27 +337,21 @@ BOOL CSession_DLStroage::Session_DLStorage_SetSeek(LPCTSTR lpszClientAddr, int n
387337 st_Locker.unlock_shared ();
388338 return FALSE ;
389339 }
390- if (bError)
391- {
392- if ((time (NULL ) - stl_MapIterator->second .st_DynamicRate .nTimeError ) > 1 )
393- {
394- stl_MapIterator->second .st_DynamicRate .nErrorCount ++;
395- stl_MapIterator->second .st_DynamicRate .nTimeError = time (NULL );
396- stl_MapIterator->second .st_DynamicRate .ullTimeWait += (XENGINE_STOREAGE_SESSION_DOWNLOAD_SENDTIME * stl_MapIterator->second .st_DynamicRate .nTimeError );
397- }
398- if (NULL != pSt_StorageRate)
399- {
400- *pSt_StorageRate = stl_MapIterator->second .st_DynamicRate ;
401- }
402- }
403- fseek (stl_MapIterator->second .pSt_File , nSeek, SEEK_CUR);
404- // 如果超过次数.返回错误
405- if (stl_MapIterator->second .st_DynamicRate .nErrorCount > m_nTryTime)
340+ if (stl_MapIterator->second .nErrorTime > m_nTryTime)
406341 {
342+ Session_IsErrorOccur = TRUE ;
343+ Session_dwErrorCode = ERROR_STORAGE_MODULE_SESSION_ERRORTIME;
407344 st_Locker.unlock_shared ();
408345 return FALSE ;
409346 }
347+ // 移动文件指针
348+ fseek (stl_MapIterator->second .pSt_File , nSeek, SEEK_CUR);
410349 stl_MapIterator->second .ullRWLen += nSeek;
350+
351+ if (bError)
352+ {
353+ stl_MapIterator->second .nErrorTime ++;
354+ }
411355 st_Locker.unlock_shared ();
412356 return TRUE ;
413357}
0 commit comments