Skip to content

Commit 40d505f

Browse files
committed
added:use speed limit with send file
1 parent a1f5e43 commit 40d505f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

XEngine_Source/XEngine_StorageApp/StorageApp_Download.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,12 @@ XHTHREAD CALLBACK XEngine_Download_HTTPThread(LPVOID lParam)
4444

4545
void CALLBACK XEngine_Download_CBSend(LPCSTR lpszClientAddr, SOCKET hSocket, LPVOID lParam)
4646
{
47+
int nTimeWait = 0;
4748
int nThreadPos = 0; //回调模式不需要发送线程池
4849
int nMsgLen = 4096;
4950
TCHAR tszMsgBuffer[4096];
51+
list<string> stl_ListClient;
52+
5053
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
5154

5255
if (Session_DLStroage_GetBuffer(nThreadPos, lpszClientAddr, tszMsgBuffer, &nMsgLen))
@@ -88,6 +91,11 @@ void CALLBACK XEngine_Download_CBSend(LPCSTR lpszClientAddr, SOCKET hSocket, LPV
8891
{
8992
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("下载客户端:%s,获取用户对应文件内容失败,错误:%lX"), lpszClientAddr, Session_GetLastError());
9093
}
94+
//限速
95+
Session_DLStroage_GetCount(nThreadPos, &stl_ListClient);
96+
Algorithm_Calculation_SleepFlow(&nTimeWait, st_ServiceCfg.st_XLimit.nMaxDNLoader, stl_ListClient.size(), 4096);
97+
stl_ListClient.clear();
98+
std::this_thread::sleep_for(std::chrono::microseconds(nTimeWait));
9199
}
92100

93101
XHTHREAD CALLBACK XEngine_Download_SendThread(LPVOID lParam)

0 commit comments

Comments
 (0)