@@ -45,9 +45,9 @@ XHTHREAD CALLBACK XEngine_Download_HTTPThread(LPVOID lParam)
4545void CALLBACK XEngine_Download_CBSend (LPCSTR lpszClientAddr, SOCKET hSocket, LPVOID lParam)
4646{
4747 int nMsgLen = 4096 ;
48+ int nListCount = 0 ;
4849 __int64u nTimeWait = 0 ;
4950 TCHAR tszMsgBuffer[4096 ];
50- list<string> stl_ListClient;
5151
5252 memset (tszMsgBuffer, ' \0 ' , sizeof (tszMsgBuffer));
5353
@@ -91,11 +91,9 @@ void CALLBACK XEngine_Download_CBSend(LPCSTR lpszClientAddr, SOCKET hSocket, LPV
9191 XLOG_PRINT (xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T (" 下载客户端:%s,获取用户对应文件内容失败,错误:%lX" ), lpszClientAddr, Session_GetLastError ());
9292 }
9393 // 限速
94- Session_DLStroage_GetCount (&stl_ListClient);
95- Algorithm_Calculation_SleepFlow (&nTimeWait, st_ServiceCfg.st_XLimit .nMaxDNLoader , stl_ListClient.size (), 4096 );
96- stl_ListClient.clear ();
97- // 计算机每次休眠时间是不一定的,*2作为修正,如果想要更准确的需要使用到 Algorithm_Calculation_Create来处理
98- std::this_thread::sleep_for (std::chrono::microseconds (nTimeWait * 2 ));
94+ Session_DLStroage_GetCount (&nListCount);
95+ Algorithm_Calculation_SleepFlow (xhLimit, &nTimeWait, st_ServiceCfg.st_XLimit .nMaxDNLoader , nListCount, 4096 );
96+ std::this_thread::sleep_for (std::chrono::microseconds (nTimeWait));
9997}
10098
10199BOOL XEngine_Task_HttpDownload (LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int nMsgLen, RFCCOMPONENTS_HTTP_REQPARAM* pSt_HTTPParam, TCHAR** pptszListHdr, int nHdrCount)
@@ -178,6 +176,11 @@ BOOL XEngine_Task_HttpDownload(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, in
178176 st_HDRParam.st_Range .nPosCount = ullCount;
179177 st_HDRParam.nHttpCode = 206 ;
180178 st_HDRParam.bIsClose = TRUE ;
179+
180+ if (0 == st_HDRParam.st_Range .nPosEnd )
181+ {
182+ st_HDRParam.st_Range .nPosEnd = ullCount;
183+ }
181184 }
182185 else
183186 {
@@ -208,17 +211,14 @@ BOOL XEngine_Task_SendDownload(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, in
208211{
209212 if (!XEngine_Net_SendMsg (lpszClientAddr, lpszMsgBuffer, nMsgLen, STORAGE_NETTYPE_HTTPDOWNLOAD))
210213 {
211- SESSION_STORAGEDYNAMICRATE st_StorageRate;
212- memset (&st_StorageRate, ' \0 ' , sizeof (SESSION_STORAGEDYNAMICRATE));
213-
214- if (Session_DLStorage_SetSeek (lpszClientAddr, -nMsgLen, TRUE , &st_StorageRate))
214+ if (Session_DLStorage_SetSeek (lpszClientAddr, -nMsgLen))
215215 {
216- XLOG_PRINT (xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _T (" 下载客户端:%s,正在发送文件数据,发送失败,移动指针:%d,错误次数:%d,等待时间:%llu 微妙,恢复次数:%d " ), lpszClientAddr, -nMsgLen, st_StorageRate. nErrorCount , st_StorageRate. ullTimeWait , st_StorageRate. nAutoNumber );
216+ XLOG_PRINT (xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _T (" 下载客户端:%s,正在发送文件数据,发送失败,移动指针:%d" ), lpszClientAddr, -nMsgLen);
217217 }
218218 else
219219 {
220220 XEngine_Net_CloseClient (lpszClientAddr, STORAGE_LEAVETYPE_CLOSE, STORAGE_NETTYPE_HTTPDOWNLOAD);
221- XLOG_PRINT (xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T (" 下载客户端:%s,正在发送文件数据,大小:%d,发送超过重试次数,无法继续,移除发送队列,错误次数:%d,等待时间:%llu 微妙,恢复次数:%d " ), lpszClientAddr, nMsgLen, st_StorageRate. nErrorCount , st_StorageRate. ullTimeWait , st_StorageRate. nAutoNumber );
221+ XLOG_PRINT (xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T (" 下载客户端:%s,正在发送文件数据,大小:%d,发送超过重试次数,无法继续,移除发送队列" ), lpszClientAddr, nMsgLen);
222222 }
223223 return FALSE ;
224224 }
0 commit comments