@@ -39,6 +39,20 @@ XHTHREAD CALLBACK XEngine_UPLoader_HTTPThread(XPVOID lParam)
39
39
}
40
40
return 0 ;
41
41
}
42
+ void CALLBACK XEngine_UPLoader_UPFlow (XHANDLE xhToken, bool bSDFlow, bool bRVFlow, bool bTime, __int64u nSDFlow, __int64u nRVFlow, __int64u nTimeFlow, XPVOID lParam)
43
+ {
44
+ XCHAR tszIPAddr[128 ] = {};
45
+ _tcsxcpy (tszIPAddr, (LPCXSTR)lParam);
46
+ if (bSDFlow)
47
+ {
48
+ NetCore_TCPXCore_PasueRecvEx (xhNetUPLoader, tszIPAddr, false );
49
+ }
50
+ else
51
+ {
52
+ NetCore_TCPXCore_PasueRecvEx (xhNetUPLoader, tszIPAddr, true );
53
+ }
54
+ XLOG_PRINT (xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X (" 上传客户端:%s,接受数据标志:%d,当前平均流量:%llu" ), tszIPAddr, bSDFlow, nSDFlow);
55
+ }
42
56
bool XEngine_Task_HttpUPLoader (LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int nMsgLen, RFCCOMPONENTS_HTTP_REQPARAM* pSt_HTTPParam, XCHAR** pptszListHdr, int nHdrCount)
43
57
{
44
58
int nSDLen = 2048 ;
@@ -292,7 +306,21 @@ bool XEngine_Task_HttpUPLoader(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, in
292
306
}
293
307
SystemApi_File_CreateMutilFolder (tszTmpPath);
294
308
}
295
- if (!Session_UPStroage_Insert (lpszClientAddr, st_StorageBucket.tszBuckKey , tszFileDir, nPosCount, st_StorageBucket.st_PermissionFlags .bRewrite , nPosStart, nPosEnd))
309
+ XHANDLE xhUPSpeed = NULL ;
310
+ if (nLimit > 0 || (st_ServiceCfg.st_XLimit .bLimitMode && st_ServiceCfg.st_XLimit .nMaxUPLoader > 0 ))
311
+ {
312
+ // 处理限速情况
313
+ XCHAR* ptszIPClient = (XCHAR*)malloc (MAX_PATH);
314
+ memset (ptszIPClient, ' \0 ' , MAX_PATH);
315
+ _tcsxcpy (ptszIPClient, lpszClientAddr);
316
+
317
+ nLimit = nLimit == 0 ? st_ServiceCfg.st_XLimit .nMaxUPLoader : nLimit;
318
+ xhUPSpeed = Algorithm_Calculation_Create ();
319
+ Algorithm_Calculation_PassiveOPen (xhUPSpeed, XEngine_UPLoader_UPFlow, nLimit, 0 , 0 , false , ptszIPClient);
320
+ NetCore_TCPXCore_PasueRecvEx (xhNetUPLoader, lpszClientAddr, false );
321
+ XLOG_PRINT (xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X (" 上传客户端:%s,上传限速被启用,文件:%s,限速:%d" ), lpszClientAddr, tszFileDir, nLimit);
322
+ }
323
+ if (!Session_UPStroage_Insert (lpszClientAddr, st_StorageBucket.tszBuckKey , tszFileDir, xhUPSpeed, nPosCount, st_StorageBucket.st_PermissionFlags .bRewrite , nLimit, nPosStart, nPosEnd))
296
324
{
297
325
st_HDRParam.bIsClose = true ;
298
326
st_HDRParam.nHttpCode = 500 ;
@@ -354,6 +382,7 @@ bool XEngine_Task_HttpUPLoader(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, in
354
382
{
355
383
Session_UPStroage_Write (lpszClientAddr, lpszMsgBuffer, nMsgLen);
356
384
}
385
+ Algorithm_Calculation_ADDSDFlow (Session_UPStroage_GetSpeed (lpszClientAddr), nMsgLen);
357
386
HttpProtocol_Server_GetRecvModeEx (xhUPHttp, lpszClientAddr, &nRVMode, &nRVCount, &nHDSize);
358
387
if (nHDSize >= nRVCount)
359
388
{
0 commit comments