Skip to content

Commit 1e5c6cd

Browse files
authored
Merge pull request #6 from libxengine/develop
V1.4 merge
2 parents ed0a7f4 + 9cdf7b6 commit 1e5c6cd

File tree

30 files changed

+504
-133
lines changed

30 files changed

+504
-133
lines changed

README.en.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ sudo dnf install jsoncpp-devel
6161

6262
##### XEngine Install
6363
you can install xengine env to your system by shell
64-
like this:sudo XEngine_RunEnv.sh -c 3
64+
like this:sudo XEngine_RunEnv.sh -i 3
6565
##### complie
6666
execute command in XEngine_Source path
6767
make complie

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Centos8.x
5858
sudo dnf install jsoncpp-devel
5959

6060
##### XEngine环境
61-
XEngine可以通过脚本文件安装sudo XEngine_RunEnv.sh -c 3
61+
XEngine可以通过脚本文件安装sudo XEngine_RunEnv.sh -i 3
6262
##### 编译命令
6363
在XEngine_Source目录下执行命令
6464
make 编译

XEngine_Docment/Docment_en.docx

53 Bytes
Binary file not shown.

XEngine_Docment/Docment_zh.docx

56 Bytes
Binary file not shown.

XEngine_Release/XEngine_Config/XEngine_Config.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"tszIPAddr": "127.0.0.1",
33
"bDeamon": 0,
4-
"nCenterPort": 5000,
5-
"nStorageDLPort": 5001,
6-
"nStorageUPPort": 5002,
4+
"nCenterPort": 5100,
5+
"nStorageDLPort": 5101,
6+
"nStorageUPPort": 5102,
77
"XMax": {
88
"MaxClient": 10000,
99
"MaxQueue": 10000,
@@ -45,22 +45,23 @@
4545
"tszAuthProxy": ""
4646
},
4747
"XProxyPass": {
48-
"bUPGet": 0,
49-
"bDLGet": 0,
50-
"tszUPPass": "http://192.168.1.7/Api/Pass/upfile",
51-
"tszDLPass": "http://192.168.1.7/Api/Pass/dlfile"
48+
"bUPGet": 1,
49+
"bDLGet": 1,
50+
"tszUPPass": "http://192.168.1.7:5200/Api/Pass/UPFile",
51+
"tszDLPass": "http://192.168.1.7:5200/Api/Pass/UPFile"
5252
}
5353
},
5454
"XLimit": {
5555
"nMaxUPLoad": 0,
56-
"nMaxDNLoad": 102400
56+
"nMaxDNLoad": 1024000
5757
},
5858
"XVer": {
5959
"StorageVersion": [
60+
"1.4.0.1001 Build20210702",
6061
"1.3.0.1001 Build20210625",
6162
"1.2.0.1001 Build20210618",
6263
"1.1.0.1001 Build20210611",
6364
"1.0.0.1001 Build20210501"
6465
]
6566
}
66-
}
67+
}

XEngine_Source/StorageModule_Config/Config_Json/Config_Json.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ BOOL CConfig_Json::Config_Json_File(LPCTSTR lpszConfigFile,XENGINE_SERVERCONFIG
147147
_tcscpy(pSt_ServerConfig->st_XProxy.st_XProxyAuth.tszAuthProxy, st_JsonXProxyAuth["tszAuthProxy"].asCString());
148148
_tcscpy(pSt_ServerConfig->st_XProxy.st_XProxyAuth.tszUserList, st_JsonXProxyAuth["tszUserList"].asCString());
149149

150-
pSt_ServerConfig->st_XProxy.st_XProxyPass.bDLPass = st_JsonXProxyPass["bDLPass"].asInt();
150+
pSt_ServerConfig->st_XProxy.st_XProxyPass.bDLPass = st_JsonXProxyPass["bDLGet"].asInt();
151151
pSt_ServerConfig->st_XProxy.st_XProxyPass.bUPPass = st_JsonXProxyPass["bUPGet"].asInt();
152152
_tcscpy(pSt_ServerConfig->st_XProxy.st_XProxyPass.tszDLPass, st_JsonXProxyPass["tszDLPass"].asCString());
153153
_tcscpy(pSt_ServerConfig->st_XProxy.st_XProxyPass.tszUPPass, st_JsonXProxyPass["tszUPPass"].asCString());

XEngine_Source/StorageModule_Session/Session_Define.h

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ typedef struct
2222
__int64x ullRWLen; //已经读取(写入)的大小
2323
__int64x ullPosStart; //开始位置
2424
__int64x ullPosEnd; //结束位置
25+
int nErrorCount; //错误次数
2526
FILE* pSt_File;
2627
}SESSION_STORAGEINFO;
2728
//////////////////////////////////////////////////////////////////////////
@@ -84,12 +85,17 @@ extern "C" BOOL Session_User_Exist(LPCTSTR lpszUser, LPCTSTR lpszPass);
8485
类型:整数型
8586
可空:N
8687
意思:输入最大运行多少个下载同时进行
88+
参数.二:nTryTime
89+
In/Out:In
90+
类型:整数型
91+
可空:N
92+
意思:输入重试次数
8793
返回值
8894
类型:逻辑型
8995
意思:是否成功
9096
备注:
9197
*********************************************************************/
92-
extern "C" BOOL Session_DLStroage_Init(int nPoolCount = 1);
98+
extern "C" BOOL Session_DLStroage_Init(int nPoolCount = 1, int nTryTime = 3);
9399
/********************************************************************
94100
函数名称:Session_DLStroage_Destory
95101
函数功能:销毁下载管理器
@@ -215,6 +221,25 @@ extern "C" BOOL Session_DLStroage_GetInfo(int nPool, int nIndex, SESSION_STORAGE
215221
*********************************************************************/
216222
extern "C" BOOL Session_DLStroage_GetCount(int nIndex, int* pInt_ListCount);
217223
/********************************************************************
224+
函数名称:Session_DLStorage_SetSeek
225+
函数功能:移动文件指针
226+
参数.一:lpszClientAddr
227+
In/Out:In
228+
类型:常量字符指针
229+
可空:N
230+
意思:输入要操作的客户端
231+
参数.二:nSeek
232+
In/Out:In
233+
类型:整数型
234+
可空:N
235+
意思:输入文件位置
236+
返回值
237+
类型:逻辑型
238+
意思:是否成功
239+
备注:
240+
*********************************************************************/
241+
extern "C" BOOL Session_DLStorage_SetSeek(LPCTSTR lpszClientAddr, int nSeek);
242+
/********************************************************************
218243
函数名称:Session_DLStroage_Delete
219244
函数功能:删除一个队列
220245
参数.一:lpszClientAddr

XEngine_Source/StorageModule_Session/Session_Stroage/Session_DLStroage.cpp

Lines changed: 71 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*********************************************************************/
1414
CSession_DLStroage::CSession_DLStroage()
1515
{
16+
m_nTryTime = 3;
1617
}
1718
CSession_DLStroage::~CSession_DLStroage()
1819
{
@@ -28,12 +29,17 @@ CSession_DLStroage::~CSession_DLStroage()
2829
类型:整数型
2930
可空:N
3031
意思:输入最大运行多少个下载同时进行
32+
参数.二:nTryTime
33+
In/Out:In
34+
类型:整数型
35+
可空:N
36+
意思:输入重试次数
3137
返回值
3238
类型:逻辑型
3339
意思:是否成功
3440
备注:
3541
*********************************************************************/
36-
BOOL CSession_DLStroage::Session_DLStroage_Init(int nPoolCount /* = 1 */)
42+
BOOL CSession_DLStroage::Session_DLStroage_Init(int nPoolCount /* = 1 */, int nTryTime /* = 3 */)
3743
{
3844
Session_IsErrorOccur = FALSE;
3945

@@ -153,11 +159,16 @@ BOOL CSession_DLStroage::Session_DLStroage_Insert(LPCTSTR lpszClientAddr, LPCTST
153159
st_Locker.unlock_shared();
154160

155161
SESSION_STORAGEINFO st_Client;
156-
struct _stat st_FStat;
162+
struct __stat64 st_FStat;
157163

158164
memset(&st_Client, '\0', sizeof(SESSION_STORAGEINFO));
159-
_stat(lpszFileDir, &st_FStat);
160-
165+
int nRet = _stat64(lpszFileDir, &st_FStat);
166+
if (-1 == nRet)
167+
{
168+
Session_IsErrorOccur = TRUE;
169+
Session_dwErrorCode = ERROR_STORAGE_MODULE_SESSION_OPENFILE;
170+
return FALSE;
171+
}
161172
st_Client.ullPosStart = nPosStart;
162173
st_Client.ullPosEnd = nPostEnd;
163174
st_Client.ullCount = st_FStat.st_size;
@@ -401,6 +412,62 @@ BOOL CSession_DLStroage::Session_DLStroage_GetCount(int nPool, int* pInt_ListCou
401412
return TRUE;
402413
}
403414
/********************************************************************
415+
函数名称:Session_DLStorage_SetSeek
416+
函数功能:移动文件指针
417+
参数.一:lpszClientAddr
418+
In/Out:In
419+
类型:常量字符指针
420+
可空:N
421+
意思:输入要操作的客户端
422+
参数.二:nSeek
423+
In/Out:In
424+
类型:整数型
425+
可空:N
426+
意思:输入文件位置
427+
返回值
428+
类型:逻辑型
429+
意思:是否成功
430+
备注:
431+
*********************************************************************/
432+
BOOL CSession_DLStroage::Session_DLStorage_SetSeek(LPCTSTR lpszClientAddr, int nSeek)
433+
{
434+
Session_IsErrorOccur = FALSE;
435+
436+
BOOL bFound = FALSE;
437+
st_Locker.lock_shared();
438+
unordered_map<int, SESSION_STORAGELIST>::iterator stl_MapIterator = stl_MapStroage.begin();
439+
for (; stl_MapIterator != stl_MapStroage.end(); stl_MapIterator++)
440+
{
441+
stl_MapIterator->second.st_Locker->lock_shared();
442+
list<SESSION_STORAGEINFO>::iterator stl_ListIterator = stl_MapIterator->second.pStl_ListStorage->begin();
443+
for (; stl_ListIterator != stl_MapIterator->second.pStl_ListStorage->end(); stl_ListIterator++)
444+
{
445+
if (0 == _tcsncmp(lpszClientAddr, stl_ListIterator->tszClientAddr, _tcslen(lpszClientAddr)))
446+
{
447+
bFound = TRUE;
448+
stl_ListIterator->nErrorCount++;
449+
fseek(stl_ListIterator->pSt_File, nSeek, SEEK_CUR);
450+
//如果超过次数.返回错误
451+
if (stl_ListIterator->nErrorCount > m_nTryTime)
452+
{
453+
stl_MapIterator->second.st_Locker->unlock_shared();
454+
st_Locker.unlock_shared();
455+
return FALSE;
456+
}
457+
break;
458+
}
459+
}
460+
stl_MapIterator->second.st_Locker->unlock_shared();
461+
462+
if (bFound)
463+
{
464+
break;
465+
}
466+
}
467+
st_Locker.unlock_shared();
468+
return TRUE;
469+
}
470+
/********************************************************************
404471
函数名称:Session_DLStroage_Delete
405472
函数功能:删除一个队列
406473
参数.一:lpszClientAddr

XEngine_Source/StorageModule_Session/Session_Stroage/Session_DLStroage.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@ class CSession_DLStroage
2222
CSession_DLStroage();
2323
~CSession_DLStroage();
2424
public:
25-
BOOL Session_DLStroage_Init(int nPoolCount = 1);
25+
BOOL Session_DLStroage_Init(int nPoolCount = 1, int nTryTime = 3);
2626
BOOL Session_DLStroage_Destory();
2727
BOOL Session_DLStroage_Insert(LPCTSTR lpszClientAddr, LPCTSTR lpszFileDir, __int64x* pInt_Count, __int64x* pInt_LeftCount, int nPosStart = 0, int nPostEnd = 0);
2828
BOOL Session_DLStroage_GetList(int nPool, int nIndex, TCHAR* ptszClientAddr, TCHAR* ptszMsgBuffer, int* pInt_MsgLen);
2929
BOOL Session_DLStroage_GetInfo(int nPool, int nIndex, SESSION_STORAGEINFO* pSt_StorageInfo);
3030
BOOL Session_DLStroage_GetCount(int nPool, int* pInt_ListCount);
31+
BOOL Session_DLStorage_SetSeek(LPCTSTR lpszClientAddr, int nSeek);
3132
BOOL Session_DLStroage_Delete(LPCTSTR lpszClientAddr);
3233
private:
34+
int m_nTryTime;
3335
shared_mutex st_Locker;
3436
private:
3537
unordered_map<int, SESSION_STORAGELIST> stl_MapStroage;

XEngine_Source/StorageModule_Session/StorageModule_Session.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ EXPORTS
1313
Session_DLStroage_GetList
1414
Session_DLStroage_GetInfo
1515
Session_DLStroage_GetCount
16+
Session_DLStorage_SetSeek
1617
Session_DLStroage_Delete
1718

1819
Session_UPStroage_Init

0 commit comments

Comments
 (0)