diff --git a/README.en.md b/README.en.md index 6777f8e..431355b 100644 --- a/README.en.md +++ b/README.en.md @@ -1,4 +1,6 @@ +[中文](README.md) || [English](README.en.md) # XEngine_Storage +This repository has a development and master branch. If you want to use it, please use the master branch ## Introduction c c++ 存储服务 c c++ 文件存储服务 @@ -10,7 +12,6 @@ best storage service for http,batter than nginx and more convenient to manage. O ## Software feature The purpose of development and implementation based on libXEngine is a cross-platform network storage service -This repository has a development and master branch. If you want to use it, please use the master branch feature list: 1. support file http upload and download(use put and get method) @@ -25,9 +26,10 @@ feature list: 10. support p2p 11. bt(planning) 12. data distributed -13. support second pass +13. support second pass and Resumable 14. support nginx upload module proxy_pass 15. support upload and download Redirect +16. dynamic rate of the download ## install @@ -85,6 +87,10 @@ The Second pass is not realized by the server, it is by the client upload file second pass is first check the HASH file is on the server, if has file on the server, it will directly prompt the upload is successful. The realization of downloading second transmission is to first query the local file save path through HASH, and download it directly if it exists. +## 关于P2P +P2P distributed download has been supported, but currently only in the lan,cross-network segment is not supported for the time being, you need to wait for the development to be completed +P2P distributed download is the same as the hyper-threaded download of other download tools. The principle is to use the HTTP RANGE field. You can implement this function through libraries such as libcurl. + ## directory struct - XEngine_Docment docment directory - XEngine_Release install directory @@ -94,7 +100,6 @@ The realization of downloading second transmission is to first query the local f ## now task expand management interface -P2P ## other problems You can refer to the document under the docment directory. It contains API protocol and service description. diff --git a/README.md b/README.md index b768d15..6436ecb 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ +[中文](README.md) || [English](README.en.md) # XEngine_Storage +本仓库有开发和主分支,如果要使用,请使用master分支下的代码 ## 介绍 c c++ 存储服务 c c++ 文件存储服务 @@ -10,7 +12,6 @@ c c++ file storage service ## 软件特性 基于libXEngine开发并实现的一套简洁高性能跨平台网络存储服务 -本仓库有开发和主分支,如果要使用,请使用master分支下的代码 软件特性: 1. 支持HTTP协议上传和下载(采用PUT和GET) 2. 支持HTTP API接口事件通知与管理 @@ -24,9 +25,10 @@ c c++ file storage service 10. 支持P2P 11. BT(规划中) 12. 数据分发 -13. 支持秒传 +13. 支持秒传和断点续传 14. 支持NGINX UPLOAD MODULE上传代理 15. 支持上传和下载重定向 +16. 下载动态速率 ## 安装教程 @@ -90,9 +92,12 @@ make FLAGS=CleanAll 清理编译 上传秒传的实现是先通过HASH查询文件是否在服务器,如果存在就不上传直接提示客户端上传成功. 下载秒传的实现是先通过HASH查询本地文件保存路径,如果存在就直接下载完成. +## 关于P2P +P2P分布式下载已经支持,不过目前只能在局域网中,暂时不支持跨网段,需要等待开发完毕 +P2P分布式下载与其他下载工具的超线程下载一样,原理是使用HTTP RANGE字段实现.各位可以通过libcurl等库实现此功能. + ## 当前任务 扩展管理接口 -实现P2P ## 其他问题 你可以参考docment目录下的文档.里面包含了API协议和服务说明. diff --git a/XEngine_APPClient/APPClient_Download/APPClient_Download.cpp b/XEngine_APPClient/APPClient_Download/APPClient_Download.cpp index f3e7813..39865e4 100644 --- a/XEngine_APPClient/APPClient_Download/APPClient_Download.cpp +++ b/XEngine_APPClient/APPClient_Download/APPClient_Download.cpp @@ -1,19 +1,149 @@ -#ifdef _WINDOWS +//P2P 分布式(超线程下载示例代码),目前仅支持局域网,示例代码仅仅是演示如何实现,正式使用需要做调整 +//P2P Distributed(Hyper-Threading download sample code),only supports LAN,The example code is just to demonstrate how to implement it, and it needs to be adjusted for business +//你可以使用libcurl实现HTTP下载功能,主要是利用了Range字段实现分块下载 +//You can use libcurl to implement the HTTP download, mainly using the Range field to achieve block download +#ifdef _WINDOWS #include #include #else #endif +#include #include #include +#include +#include #include #include #include #include +#include +#include +#include +#include +#include +using namespace std; #pragma comment(lib,"x86/XEngine_BaseLib/XEngine_BaseLib") #pragma comment(lib,"x86/XEngine_NetHelp/NetHelp_APIHelp") +#pragma comment(lib,"x86/XEngine_DownLoad/XEngine_DownLoad") +#pragma comment(lib,"x86/XEngine_SystemSdk/XEngine_SystemApi") #pragma comment(lib,"Ws2_32") +typedef struct +{ + XENGINE_PROTOCOLFILE st_ProtocolFile; + CHAR tszIPAddr[64]; +}P2PFILE_INFO; + +//解析局域网中所有文件 +void P2PParse_List(LPCTSTR lpszMsgBuffer, int nMsgLen, list* pStl_ListFile) +{ + Json::Value st_JsonRoot; + Json::CharReaderBuilder st_JsonBuild; + Json::CharReader* pSt_JsonReader(st_JsonBuild.newCharReader()); + + JSONCPP_STRING st_JsonError; + //解析JSON + if (!pSt_JsonReader->parse(lpszMsgBuffer, lpszMsgBuffer + nMsgLen, &st_JsonRoot, &st_JsonError)) + { + return; + } + delete pSt_JsonReader; + pSt_JsonReader = NULL; + + int nCount = st_JsonRoot["Count"].asInt(); + Json::Value st_JsonArray = st_JsonRoot["List"]; + for (int i = 0; i < nCount; i++) + { + P2PFILE_INFO st_P2PFile; + memset(&st_P2PFile, '\0', sizeof(P2PFILE_INFO)); + + st_P2PFile.st_ProtocolFile.nFileSize = st_JsonArray[i]["nFileSize"].asInt(); + _tcscpy(st_P2PFile.st_ProtocolFile.tszFileHash, st_JsonArray[i]["tszFileHash"].asCString()); + _tcscpy(st_P2PFile.st_ProtocolFile.tszFileName, st_JsonArray[i]["tszFileName"].asCString()); + _tcscpy(st_P2PFile.st_ProtocolFile.tszFilePath, st_JsonArray[i]["tszFilePath"].asCString()); + _tcscpy(st_P2PFile.st_ProtocolFile.tszFileTime, st_JsonArray[i]["tszFileTime"].asCString()); + _tcscpy(st_P2PFile.st_ProtocolFile.tszFileUser, st_JsonArray[i]["tszFileUser"].asCString()); + _tcscpy(st_P2PFile.tszIPAddr, st_JsonArray[i]["tszTableName"].asCString()); + + pStl_ListFile->push_back(st_P2PFile); + } +} +//创建分布式文件下载器 +typedef struct +{ + XNETHANDLE xhToken; //下载句柄 + __int64x nPosStart; + __int64x nPosEnd; +}P2PFILE_PIECE; +void P2PFile_Create(list* pStl_ListFile, LPCTSTR lpszFile) +{ + P2PFILE_PIECE* pSt_P2PFile = new P2PFILE_PIECE[pStl_ListFile->size()]; + + int nPos = 0; + //得到每个块大小 + int nPiece = pStl_ListFile->front().st_ProtocolFile.nFileSize / pStl_ListFile->size(); + //这是一个简单的分布式块算法示例.怎么做分布式,可以根据自己需求做算法拆解 + list::const_iterator stl_ListIterator = pStl_ListFile->begin(); + for (int i = 0; stl_ListIterator != pStl_ListFile->end(); stl_ListIterator++, i++) + { + TCHAR tszDLUrl[MAX_PATH]; + TCHAR tszRange[128]; + + memset(tszDLUrl, '\0', MAX_PATH); + memset(tszRange, '\0', sizeof(tszRange)); + + _stprintf(tszDLUrl, _T("%s/%s/%s"), stl_ListIterator->tszIPAddr, stl_ListIterator->st_ProtocolFile.tszFilePath + 2, stl_ListIterator->st_ProtocolFile.tszFileName); + //是否是最后一块 + if (pStl_ListFile->size() == (i + 1)) + { + pSt_P2PFile[i].nPosStart = nPos; + pSt_P2PFile[i].nPosEnd = 0; + _stprintf(tszRange, _T("%lld-"), pSt_P2PFile[i].nPosStart); + } + else + { + pSt_P2PFile[i].nPosStart = nPos; + pSt_P2PFile[i].nPosEnd = nPiece; + nPos += nPiece; + _stprintf(tszRange, _T("%lld-%lld"), pSt_P2PFile[i].nPosStart, pSt_P2PFile[i].nPosEnd); + } + + if (!DownLoad_Http_Create(&pSt_P2PFile[i].xhToken, tszDLUrl, lpszFile, tszRange, NULL, NULL, NULL)) + { + printf("create download task is failed:%lX\n", Download_GetLastError()); + } + } + //直到所有完成 + while (1) + { + BOOL bComplete = TRUE; + for (unsigned int i = 0; i < pStl_ListFile->size(); i++) + { + NETDOWNLOAD_TASKINFO st_TaskInfo; + memset(&st_TaskInfo, '\0', sizeof(NETDOWNLOAD_TASKINFO)); + + DownLoad_Http_Query(pSt_P2PFile[i].xhToken, &st_TaskInfo); + if (ENUM_XENGINE_DOWNLOAD_STATUS_COMPLETE != st_TaskInfo.en_DownStatus) + { + bComplete = FALSE; + } + printf("DLToken:%lld DLTotal:%lf DLNow:%lf DLStatus:%d\n", pSt_P2PFile[i].xhToken, st_TaskInfo.dlTotal, st_TaskInfo.dlNow, st_TaskInfo.en_DownStatus); + } + if (bComplete) + { + break; + } + Sleep(500); + } + + for (unsigned int i = 0; i < pStl_ListFile->size(); i++) + { + DownLoad_Http_Delete(pSt_P2PFile[i].xhToken); + } + delete[] pSt_P2PFile; + pSt_P2PFile = NULL; +} int main() { @@ -24,13 +154,25 @@ int main() int nBodyLen = 2048; TCHAR *ptszMsgBody = NULL; //请求分布式存储文件所有位置 - LPCTSTR lpszUrl = _T("http://192.168.1.7:5100/EC9B9B75A04F3B323EFD348F9B795539"); + LPCTSTR lpszUrl = _T("http://127.0.0.1:5100/7D54D6E40367F2763B8C8056EADC517F"); + LPCTSTR lpszFile = _T("D:\\XEngine_Storage\\XEngine_APPClient\\Debug\\qq.exe"); + if (!APIHelp_HttpRequest_Get(lpszUrl, &ptszMsgBody, &nBodyLen, &nHTTPCode)) { return -1; } printf("%s\n", ptszMsgBody); + list stl_ListFile; + P2PParse_List(ptszMsgBody, nBodyLen, &stl_ListFile); + + //创建稀疏文件(一个空白的文件) + if (!SystemApi_File_CreateSparseFile(lpszFile, stl_ListFile.front().st_ProtocolFile.nFileSize)) + { + return -1; + } + P2PFile_Create(&stl_ListFile, lpszFile); + BaseLib_OperatorMemory_FreeCStyle((VOID**)&ptszMsgBody); WSACleanup(); return 0; diff --git a/XEngine_APPClient/APPClient_Download/APPClient_Download.vcxproj b/XEngine_APPClient/APPClient_Download/APPClient_Download.vcxproj index f631a41..a712002 100644 --- a/XEngine_APPClient/APPClient_Download/APPClient_Download.vcxproj +++ b/XEngine_APPClient/APPClient_Download/APPClient_Download.vcxproj @@ -88,7 +88,7 @@ Level3 true - WIN32;_DEBUG;_CONSOLE;_WINDOWS;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true diff --git a/XEngine_Docment/.gitignore b/XEngine_Docment/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/XEngine_Docment/Docment_en.docx b/XEngine_Docment/Docment_en.docx index f1d7c49..de63b8a 100644 Binary files a/XEngine_Docment/Docment_en.docx and b/XEngine_Docment/Docment_en.docx differ diff --git a/XEngine_Docment/Docment_zh.docx b/XEngine_Docment/Docment_zh.docx index be8605b..e723020 100644 Binary files a/XEngine_Docment/Docment_zh.docx and b/XEngine_Docment/Docment_zh.docx differ diff --git a/XEngine_Release/XEngine_Config/XEngine_Config.json b/XEngine_Release/XEngine_Config/XEngine_Config.json index 169d9b6..cb98caf 100644 --- a/XEngine_Release/XEngine_Config/XEngine_Config.json +++ b/XEngine_Release/XEngine_Config/XEngine_Config.json @@ -1,5 +1,5 @@ { - "tszIPAddr": "192.168.1.7", + "tszIPAddr": "192.168.1.9", "bDeamon": 0, "nCenterPort": 5100, "nStorageDLPort": 5101, @@ -38,7 +38,7 @@ "XStorage": { "nHashMode": 2, "bRename": 0, - "tszFileDir": "./XEngine_File" + "tszFileDir": "/home/ubuntu/桌面/XEngine_Storage/XEngine_Source/Debug/XEngine_File" }, "XProxy": { "XProxyAuth": { @@ -54,11 +54,13 @@ } }, "XLimit": { + "nDLTry": 100, + "nDLError": 10, "nMaxUPLoad": 0, - "nMaxDNLoad": 1024000 + "nMaxDNLoad": 10240000 }, "XP2xp": { - "nMode": 0, + "nMode": 2, "nTime": 2, "nSDPort": 15000, "nRVPort": 15001, @@ -66,6 +68,7 @@ }, "XVer": { "StorageVersion": [ + "2.2.0.1001 Build20210820", "2.1.0.1001 Build20210805", "2.0.0.1001 Build20210723", "1.5.0.1001 Build20210716", @@ -76,4 +79,4 @@ "1.0.0.1001 Build20210501" ] } -} +} \ No newline at end of file diff --git a/XEngine_Source/StorageModule_Config/Config_Define.h b/XEngine_Source/StorageModule_Config/Config_Define.h index dd86743..a8552c0 100644 --- a/XEngine_Source/StorageModule_Config/Config_Define.h +++ b/XEngine_Source/StorageModule_Config/Config_Define.h @@ -84,6 +84,8 @@ typedef struct tag_XEngine_ServerConfig }st_XProxy; struct { + int nDLTry; + int nDLError; __int64x nMaxUPLoader; __int64x nMaxDNLoader; }st_XLimit; diff --git a/XEngine_Source/StorageModule_Config/Config_Json/Config_Json.cpp b/XEngine_Source/StorageModule_Config/Config_Json/Config_Json.cpp index deecf3b..5f47aba 100644 --- a/XEngine_Source/StorageModule_Config/Config_Json/Config_Json.cpp +++ b/XEngine_Source/StorageModule_Config/Config_Json/Config_Json.cpp @@ -155,13 +155,15 @@ BOOL CConfig_Json::Config_Json_File(LPCTSTR lpszConfigFile,XENGINE_SERVERCONFIG _tcscpy(pSt_ServerConfig->st_XProxy.st_XProxyPass.tszDLPass, st_JsonXProxyPass["tszDLPass"].asCString()); _tcscpy(pSt_ServerConfig->st_XProxy.st_XProxyPass.tszUPPass, st_JsonXProxyPass["tszUPPass"].asCString()); - if (st_JsonRoot["XLimit"].empty() || (2 != st_JsonRoot["XLimit"].size())) + if (st_JsonRoot["XLimit"].empty() || (4 != st_JsonRoot["XLimit"].size())) { Config_IsErrorOccur = TRUE; Config_dwErrorCode = ERROR_XENGINE_BLOGIC_CONFIG_JSON_XSTORAGE; return FALSE; } Json::Value st_JsonXLimit = st_JsonRoot["XLimit"]; + pSt_ServerConfig->st_XLimit.nDLTry = st_JsonXLimit["nDLTry"].asUInt(); + pSt_ServerConfig->st_XLimit.nDLError = st_JsonXLimit["nDLError"].asUInt(); pSt_ServerConfig->st_XLimit.nMaxDNLoader = st_JsonXLimit["nMaxDNLoad"].asInt64(); pSt_ServerConfig->st_XLimit.nMaxUPLoader = st_JsonXLimit["nMaxUPLoad"].asInt64(); diff --git a/XEngine_Source/StorageModule_Session/Makefile b/XEngine_Source/StorageModule_Session/Makefile index fef1f50..57315ce 100644 --- a/XEngine_Source/StorageModule_Session/Makefile +++ b/XEngine_Source/StorageModule_Session/Makefile @@ -2,8 +2,8 @@ CC = g++ -Wall -std=c++17 -fPIC RELEASE = 0 UNICODE = 0 INCLUDE = -I ./ -LOADBIN = -LIB = +LOADBIN = -L /usr/local/lib/XEngine_Release/XEngine_BaseLib +LIB = -lXEngine_BaseLib LIBEX = -static-libgcc -lrt -ldl -lpthread LOADSO = -Wl,-rpath= LIBINCLUDE = Session_DLStroage.o Session_UPStroage.o Session_User.o pch.o diff --git a/XEngine_Source/StorageModule_Session/Session_Define.h b/XEngine_Source/StorageModule_Session/Session_Define.h index 2e74b7c..316cd8e 100644 --- a/XEngine_Source/StorageModule_Session/Session_Define.h +++ b/XEngine_Source/StorageModule_Session/Session_Define.h @@ -15,6 +15,15 @@ ////////////////////////////////////////////////////////////////////////// typedef struct { + ULONGLONG ullTimeSend; //最后发送时间 + ULONGLONG ullTimeWait; //等待恢复时间,单位毫秒 + time_t nTimeError; //最后错误时间 + int nErrorCount; //错误次数 + int nAutoNumber; //恢复次数 +}SESSION_STORAGEDYNAMICRATE; +typedef struct +{ + SESSION_STORAGEDYNAMICRATE st_DynamicRate; TCHAR tszFileDir[MAX_PATH]; //文件地址 TCHAR tszClientAddr[128]; //操作的用户地址 __int64x ullCount; //总大小 @@ -22,7 +31,6 @@ typedef struct __int64x ullRWLen; //已经读取(写入)的大小 __int64x ullPosStart; //开始位置 __int64x ullPosEnd; //结束位置 - int nErrorCount; //错误次数 FILE* pSt_File; }SESSION_STORAGEINFO; ////////////////////////////////////////////////////////////////////////// @@ -88,14 +96,19 @@ extern "C" BOOL Session_User_Exist(LPCTSTR lpszUser, LPCTSTR lpszPass); 参数.二:nTryTime In/Out:In 类型:整数型 - 可空:N + 可空:Y 意思:输入重试次数 + 参数.三:nAutoSpeed + In/Out:In + 类型:整数型 + 可空:Y + 意思:输入恢复次数,超过次数不在恢复 返回值 类型:逻辑型 意思:是否成功 备注: *********************************************************************/ -extern "C" BOOL Session_DLStroage_Init(int nPoolCount = 1, int nTryTime = 3); +extern "C" BOOL Session_DLStroage_Init(int nPoolCount = 1, int nTryTime = 3, int nAutoSpeed = 3); /******************************************************************** 函数名称:Session_DLStroage_Destory 函数功能:销毁下载管理器 @@ -152,23 +165,18 @@ extern "C" BOOL Session_DLStroage_Insert(LPCTSTR lpszClientAddr, LPCTSTR lpszFil 类型:整数型 可空:N 意思:输入要操作的队列 - 参数.二:nIndex + 参数.二:lpszClientAddr In/Out:In - 类型:整数型 - 可空:N - 意思:输入要操作的队列索引 - 参数.三:ptszClientAddr - In/Out:In - 类型:整数型 + 类型:常量字符指针 可空:N - 意思:输出客户端地址 - 参数.四:ptszMsgBuffer + 意思:输入客户端地址 + 参数.三:ptszMsgBuffer In/Out:In - 类型:整数型 + 类型:字符指针 可空:N - 参数.五:pInt_MsgLen + 参数.四:pInt_MsgLen In/Out:In - 类型:整数型 + 类型:整数型指针 可空:N 意思:输出获取的缓冲区大小 返回值 @@ -176,7 +184,7 @@ extern "C" BOOL Session_DLStroage_Insert(LPCTSTR lpszClientAddr, LPCTSTR lpszFil 意思:是否成功 备注: *********************************************************************/ -extern "C" BOOL Session_DLStroage_GetList(int nPool, int nIndex, TCHAR* ptszClientAddr, TCHAR* ptszMsgBuffer, int* pInt_MsgLen); +extern "C" BOOL Session_DLStroage_GetList(int nPool, LPCTSTR lpszClientAddr, TCHAR * ptszMsgBuffer, int* pInt_MsgLen); /******************************************************************** 函数名称:Session_DLStroage_GetInfo 函数功能:获取下载信息 @@ -185,11 +193,11 @@ extern "C" BOOL Session_DLStroage_GetList(int nPool, int nIndex, TCHAR* ptszClie 类型:整数型 可空:N 意思:输入要操作的下载池 - 参数.二:nIndex + 参数.二:lpszClientAddr In/Out:In - 类型:整数型 + 类型:常量字符指针 可空:N - 意思:输入要操作的索引 + 意思:输入要操作的客户端 参数.三:pSt_StorageInfo In/Out:Out 类型:数据结构指针 @@ -200,7 +208,7 @@ extern "C" BOOL Session_DLStroage_GetList(int nPool, int nIndex, TCHAR* ptszClie 意思:是否成功 备注: *********************************************************************/ -extern "C" BOOL Session_DLStroage_GetInfo(int nPool, int nIndex, SESSION_STORAGEINFO* pSt_StorageInfo); +extern "C" BOOL Session_DLStroage_GetInfo(int nPool, LPCTSTR lpszClientAddr, SESSION_STORAGEINFO* pSt_StorageInfo); /******************************************************************** 函数名称:Session_DLStroage_GetCount 函数功能:获取队列拥有的个数 @@ -209,17 +217,17 @@ extern "C" BOOL Session_DLStroage_GetInfo(int nPool, int nIndex, SESSION_STORAGE 类型:整数型 可空:N 意思:输入要操作的队列 - 参数.二:pInt_ListCount + 参数.二:pStl_ListClient In/Out:Out - 类型:整数型指针 + 类型:STL容器指针 可空:N - 意思:输出队列个数 + 意思:输出要发送的队列个数 返回值 类型:逻辑型 意思:是否成功 备注: *********************************************************************/ -extern "C" BOOL Session_DLStroage_GetCount(int nIndex, int* pInt_ListCount); +extern "C" BOOL Session_DLStroage_GetCount(int nPool, list*pStl_ListClient); /******************************************************************** 函数名称:Session_DLStorage_SetSeek 函数功能:移动文件指针 @@ -233,12 +241,22 @@ extern "C" BOOL Session_DLStroage_GetCount(int nIndex, int* pInt_ListCount); 类型:整数型 可空:N 意思:输入文件位置 + 参数.三:bError + In/Out:In + 类型:逻辑型 + 可空:Y + 意思:是否因为错误引起的 + 参数.四:pSt_StorageRate + In/Out:In + 类型:数据结构指针 + 可空:Y + 意思:输出速率错误信息 返回值 类型:逻辑型 意思:是否成功 备注: *********************************************************************/ -extern "C" BOOL Session_DLStorage_SetSeek(LPCTSTR lpszClientAddr, int nSeek); +extern "C" BOOL Session_DLStorage_SetSeek(LPCTSTR lpszClientAddr, int nSeek, BOOL bError = TRUE, SESSION_STORAGEDYNAMICRATE * pSt_StorageRate = NULL); /******************************************************************** 函数名称:Session_DLStroage_Delete 函数功能:删除一个队列 diff --git a/XEngine_Source/StorageModule_Session/Session_Stroage/Session_DLStroage.cpp b/XEngine_Source/StorageModule_Session/Session_Stroage/Session_DLStroage.cpp index b7d55c7..5df6a6f 100644 --- a/XEngine_Source/StorageModule_Session/Session_Stroage/Session_DLStroage.cpp +++ b/XEngine_Source/StorageModule_Session/Session_Stroage/Session_DLStroage.cpp @@ -13,7 +13,6 @@ *********************************************************************/ CSession_DLStroage::CSession_DLStroage() { - m_nTryTime = 3; } CSession_DLStroage::~CSession_DLStroage() { @@ -32,14 +31,19 @@ CSession_DLStroage::~CSession_DLStroage() 参数.二:nTryTime In/Out:In 类型:整数型 - 可空:N + 可空:Y 意思:输入重试次数 + 参数.三:nAutoSpeed + In/Out:In + 类型:整数型 + 可空:Y + 意思:输入恢复次数,超过次数不在恢复 返回值 类型:逻辑型 意思:是否成功 备注: *********************************************************************/ -BOOL CSession_DLStroage::Session_DLStroage_Init(int nPoolCount /* = 1 */, int nTryTime /* = 3 */) +BOOL CSession_DLStroage::Session_DLStroage_Init(int nPoolCount /* = 1 */, int nTryTime /* = 3 */, int nAutoSpeed /* = 3 */) { Session_IsErrorOccur = FALSE; @@ -54,6 +58,8 @@ BOOL CSession_DLStroage::Session_DLStroage_Init(int nPoolCount /* = 1 */, int nT stl_MapStroage.insert(make_pair(i, st_StorageList)); st_Locker.unlock(); } + m_nTryTime = nTryTime; + m_nTryAuto = nAutoSpeed; return TRUE; } /******************************************************************** @@ -238,23 +244,18 @@ BOOL CSession_DLStroage::Session_DLStroage_Insert(LPCTSTR lpszClientAddr, LPCTST 类型:整数型 可空:N 意思:输入要操作的队列 - 参数.二:nIndex + 参数.二:lpszClientAddr In/Out:In - 类型:整数型 - 可空:N - 意思:输入要操作的队列索引 - 参数.三:ptszClientAddr - In/Out:In - 类型:整数型 + 类型:常量字符指针 可空:N - 意思:输出客户端地址 - 参数.四:ptszMsgBuffer + 意思:输入客户端地址 + 参数.三:ptszMsgBuffer In/Out:In - 类型:整数型 + 类型:字符指针 可空:N - 参数.五:pInt_MsgLen + 参数.四:pInt_MsgLen In/Out:In - 类型:整数型 + 类型:整数型指针 可空:N 意思:输出获取的缓冲区大小 返回值 @@ -262,11 +263,11 @@ BOOL CSession_DLStroage::Session_DLStroage_Insert(LPCTSTR lpszClientAddr, LPCTST 意思:是否成功 备注: *********************************************************************/ -BOOL CSession_DLStroage::Session_DLStroage_GetList(int nPool, int nIndex, TCHAR* ptszClientAddr, TCHAR* ptszMsgBuffer, int* pInt_MsgLen) +BOOL CSession_DLStroage::Session_DLStroage_GetList(int nPool, LPCTSTR lpszClientAddr, TCHAR* ptszMsgBuffer, int* pInt_MsgLen) { Session_IsErrorOccur = FALSE; - if ((NULL == ptszClientAddr) || (NULL == ptszMsgBuffer)) + if ((NULL == lpszClientAddr) || (NULL == ptszMsgBuffer) || (NULL == pInt_MsgLen)) { Session_IsErrorOccur = TRUE; Session_dwErrorCode = ERROR_STORAGE_MODULE_SESSION_PARAMENT; @@ -286,10 +287,8 @@ BOOL CSession_DLStroage::Session_DLStroage_GetList(int nPool, int nIndex, TCHAR* list::iterator stl_ListIterator = stl_MapIterator->second.pStl_ListStorage->begin(); for (int i = 0; stl_ListIterator != stl_MapIterator->second.pStl_ListStorage->end(); stl_ListIterator++, i++) { - if (nIndex == i) + if (0 == _tcsncmp(lpszClientAddr, stl_ListIterator->tszClientAddr, _tcslen(lpszClientAddr))) { - _tcscpy(ptszClientAddr, stl_ListIterator->tszClientAddr); - if (stl_ListIterator->ullRWLen >= stl_ListIterator->ullRWCount) { *pInt_MsgLen = 0; @@ -318,11 +317,11 @@ BOOL CSession_DLStroage::Session_DLStroage_GetList(int nPool, int nIndex, TCHAR* 类型:整数型 可空:N 意思:输入要操作的下载池 - 参数.二:nIndex + 参数.二:lpszClientAddr In/Out:In - 类型:整数型 + 类型:常量字符指针 可空:N - 意思:输入要操作的索引 + 意思:输入要操作的客户端 参数.三:pSt_StorageInfo In/Out:Out 类型:数据结构指针 @@ -333,7 +332,7 @@ BOOL CSession_DLStroage::Session_DLStroage_GetList(int nPool, int nIndex, TCHAR* 意思:是否成功 备注: *********************************************************************/ -BOOL CSession_DLStroage::Session_DLStroage_GetInfo(int nPool, int nIndex, SESSION_STORAGEINFO* pSt_StorageInfo) +BOOL CSession_DLStroage::Session_DLStroage_GetInfo(int nPool, LPCTSTR lpszClientAddr, SESSION_STORAGEINFO* pSt_StorageInfo) { Session_IsErrorOccur = FALSE; @@ -357,7 +356,7 @@ BOOL CSession_DLStroage::Session_DLStroage_GetInfo(int nPool, int nIndex, SESSIO list::iterator stl_ListIterator = stl_MapIterator->second.pStl_ListStorage->begin(); for (int i = 0; stl_ListIterator != stl_MapIterator->second.pStl_ListStorage->end(); stl_ListIterator++, i++) { - if (nIndex == i) + if (0 == _tcsncmp(lpszClientAddr, stl_ListIterator->tszClientAddr, _tcslen(lpszClientAddr))) { *pSt_StorageInfo = *stl_ListIterator; break; @@ -375,21 +374,21 @@ BOOL CSession_DLStroage::Session_DLStroage_GetInfo(int nPool, int nIndex, SESSIO 类型:整数型 可空:N 意思:输入要操作的队列 - 参数.二:pInt_ListCount + 参数.二:pStl_ListClient In/Out:Out - 类型:整数型指针 + 类型:STL容器指针 可空:N - 意思:输出队列个数 + 意思:输出要发送的队列个数 返回值 类型:逻辑型 意思:是否成功 备注: *********************************************************************/ -BOOL CSession_DLStroage::Session_DLStroage_GetCount(int nPool, int* pInt_ListCount) +BOOL CSession_DLStroage::Session_DLStroage_GetCount(int nPool, list* pStl_ListClient) { Session_IsErrorOccur = FALSE; - if (NULL == pInt_ListCount) + if (NULL == pStl_ListClient) { Session_IsErrorOccur = TRUE; Session_dwErrorCode = ERROR_STORAGE_MODULE_SESSION_PARAMENT; @@ -406,7 +405,45 @@ BOOL CSession_DLStroage::Session_DLStroage_GetCount(int nPool, int* pInt_ListCou return FALSE; } stl_MapIterator->second.st_Locker->lock_shared(); - *pInt_ListCount = stl_MapIterator->second.pStl_ListStorage->size(); + list::iterator stl_ListIterator = stl_MapIterator->second.pStl_ListStorage->begin(); + for (; stl_ListIterator != stl_MapIterator->second.pStl_ListStorage->end(); stl_ListIterator++) + { + //是否需要等待恢复 + if (stl_ListIterator->st_DynamicRate.ullTimeWait > 0) + { + XENGINE_VALTIME st_TimeVal; + time_t nTimeNow = time(NULL); + + memset(&st_TimeVal, '\0', sizeof(XENGINE_VALTIME)); + BaseLib_OperatorTime_GetTimeOfday(&st_TimeVal); + if (((st_TimeVal.tv_value - stl_ListIterator->st_DynamicRate.ullTimeSend) > stl_ListIterator->st_DynamicRate.ullTimeWait) && ((nTimeNow - stl_ListIterator->st_DynamicRate.nTimeError) > 1)) + { + //等待时间超过,可以加入 + pStl_ListClient->push_back(stl_ListIterator->tszClientAddr); + stl_ListIterator->st_DynamicRate.ullTimeSend = st_TimeVal.tv_value; + } + //速率恢复测算 + if ((stl_ListIterator->st_DynamicRate.nAutoNumber <= m_nTryAuto) && ((nTimeNow - stl_ListIterator->st_DynamicRate.nTimeError) > (stl_ListIterator->st_DynamicRate.nErrorCount * stl_ListIterator->st_DynamicRate.nAutoNumber))) + { + //printf("nAutoNumber:%d <= m_nTryAuto:%d,nTimeNow:%lu - nTimeError:%lu nErrorCount:%d\n", stl_ListIterator->st_DynamicRate.nAutoNumber, m_nTryAuto, nTimeNow, stl_ListIterator->st_DynamicRate.nTimeError, stl_ListIterator->st_DynamicRate.nErrorCount * stl_ListIterator->st_DynamicRate.nAutoNumber); + stl_ListIterator->st_DynamicRate.nAutoNumber++; + stl_ListIterator->st_DynamicRate.nErrorCount--; + stl_ListIterator->st_DynamicRate.ullTimeWait -= XENGINE_STOREAGE_SESSION_DOWNLOAD_SENDTIME; + if (0 == stl_ListIterator->st_DynamicRate.nErrorCount) + { + stl_ListIterator->st_DynamicRate.nTimeError = 0; + } + else + { + stl_ListIterator->st_DynamicRate.nTimeError = nTimeNow; + } + } + } + else + { + pStl_ListClient->push_back(stl_ListIterator->tszClientAddr); + } + } stl_MapIterator->second.st_Locker->unlock_shared(); st_Locker.unlock_shared(); return TRUE; @@ -424,12 +461,22 @@ BOOL CSession_DLStroage::Session_DLStroage_GetCount(int nPool, int* pInt_ListCou 类型:整数型 可空:N 意思:输入文件位置 + 参数.三:bError + In/Out:In + 类型:逻辑型 + 可空:Y + 意思:是否因为错误引起的 + 参数.四:pSt_StorageRate + In/Out:In + 类型:数据结构指针 + 可空:Y + 意思:输出速率错误信息 返回值 类型:逻辑型 意思:是否成功 备注: *********************************************************************/ -BOOL CSession_DLStroage::Session_DLStorage_SetSeek(LPCTSTR lpszClientAddr, int nSeek) +BOOL CSession_DLStroage::Session_DLStorage_SetSeek(LPCTSTR lpszClientAddr, int nSeek, BOOL bError /* = TRUE */, SESSION_STORAGEDYNAMICRATE* pSt_StorageRate /* = NULL */) { Session_IsErrorOccur = FALSE; @@ -445,15 +492,28 @@ BOOL CSession_DLStroage::Session_DLStorage_SetSeek(LPCTSTR lpszClientAddr, int n if (0 == _tcsncmp(lpszClientAddr, stl_ListIterator->tszClientAddr, _tcslen(lpszClientAddr))) { bFound = TRUE; - stl_ListIterator->nErrorCount++; + if (bError) + { + if ((time(NULL) - stl_ListIterator->st_DynamicRate.nTimeError) > 1) + { + stl_ListIterator->st_DynamicRate.nErrorCount++; + stl_ListIterator->st_DynamicRate.nTimeError = time(NULL); + stl_ListIterator->st_DynamicRate.ullTimeWait += XENGINE_STOREAGE_SESSION_DOWNLOAD_SENDTIME; + } + if (NULL != pSt_StorageRate) + { + *pSt_StorageRate = stl_ListIterator->st_DynamicRate; + } + } fseek(stl_ListIterator->pSt_File, nSeek, SEEK_CUR); //如果超过次数.返回错误 - if (stl_ListIterator->nErrorCount > m_nTryTime) + if (stl_ListIterator->st_DynamicRate.nErrorCount > m_nTryTime) { stl_MapIterator->second.st_Locker->unlock_shared(); st_Locker.unlock_shared(); return FALSE; } + stl_ListIterator->ullRWLen += nSeek; break; } } diff --git a/XEngine_Source/StorageModule_Session/Session_Stroage/Session_DLStroage.h b/XEngine_Source/StorageModule_Session/Session_Stroage/Session_DLStroage.h index 35b5d41..67b7944 100644 --- a/XEngine_Source/StorageModule_Session/Session_Stroage/Session_DLStroage.h +++ b/XEngine_Source/StorageModule_Session/Session_Stroage/Session_DLStroage.h @@ -10,6 +10,8 @@ // Purpose: 存储下载会话 // History: *********************************************************************/ +#define XENGINE_STOREAGE_SESSION_DOWNLOAD_SENDTIME 10 + typedef struct { shared_ptr st_Locker; @@ -22,17 +24,18 @@ class CSession_DLStroage CSession_DLStroage(); ~CSession_DLStroage(); public: - BOOL Session_DLStroage_Init(int nPoolCount = 1, int nTryTime = 3); + BOOL Session_DLStroage_Init(int nPoolCount = 1, int nTryTime = 3, int nAutoSpeed = 3); BOOL Session_DLStroage_Destory(); BOOL Session_DLStroage_Insert(LPCTSTR lpszClientAddr, LPCTSTR lpszFileDir, __int64x* pInt_Count, __int64x* pInt_LeftCount, int nPosStart = 0, int nPostEnd = 0); - BOOL Session_DLStroage_GetList(int nPool, int nIndex, TCHAR* ptszClientAddr, TCHAR* ptszMsgBuffer, int* pInt_MsgLen); - BOOL Session_DLStroage_GetInfo(int nPool, int nIndex, SESSION_STORAGEINFO* pSt_StorageInfo); - BOOL Session_DLStroage_GetCount(int nPool, int* pInt_ListCount); - BOOL Session_DLStorage_SetSeek(LPCTSTR lpszClientAddr, int nSeek); + BOOL Session_DLStroage_GetList(int nPool, LPCTSTR lpszClientAddr, TCHAR* ptszMsgBuffer, int* pInt_MsgLen); + BOOL Session_DLStroage_GetInfo(int nPool, LPCTSTR lpszClientAddr, SESSION_STORAGEINFO* pSt_StorageInfo); + BOOL Session_DLStroage_GetCount(int nPool, list* pStl_ListClient); + BOOL Session_DLStorage_SetSeek(LPCTSTR lpszClientAddr, int nSeek, BOOL bError = TRUE, SESSION_STORAGEDYNAMICRATE* pSt_StorageRate = NULL); BOOL Session_DLStroage_Delete(LPCTSTR lpszClientAddr); private: int m_nTryTime; + int m_nTryAuto; shared_mutex st_Locker; private: unordered_map stl_MapStroage; -}; +}; \ No newline at end of file diff --git a/XEngine_Source/StorageModule_Session/pch.cpp b/XEngine_Source/StorageModule_Session/pch.cpp index bba9275..e2b6e06 100644 --- a/XEngine_Source/StorageModule_Session/pch.cpp +++ b/XEngine_Source/StorageModule_Session/pch.cpp @@ -48,9 +48,9 @@ extern "C" BOOL Session_User_Exist(LPCTSTR lpszUser, LPCTSTR lpszPass) /************************************************************************/ /* 存储会话导出的函数 */ /************************************************************************/ -extern "C" BOOL Session_DLStroage_Init(int nPoolCount, int nTryTime) +extern "C" BOOL Session_DLStroage_Init(int nPoolCount, int nTryTime, int nAutoSpeed) { - return m_DLStorage.Session_DLStroage_Init(nPoolCount, nTryTime); + return m_DLStorage.Session_DLStroage_Init(nPoolCount, nTryTime, nAutoSpeed); } extern "C" BOOL Session_DLStroage_Destory() { @@ -60,21 +60,21 @@ extern "C" BOOL Session_DLStroage_Insert(LPCTSTR lpszClientAddr, LPCTSTR lpszFil { return m_DLStorage.Session_DLStroage_Insert(lpszClientAddr, lpszFileDir, pInt_Count, pInt_LeftCount, nPosStart, nPostEnd); } -extern "C" BOOL Session_DLStroage_GetList(int nPool, int nIndex, TCHAR * ptszClientAddr, TCHAR * ptszMsgBuffer, int* pInt_MsgLen) +extern "C" BOOL Session_DLStroage_GetList(int nPool, LPCTSTR lpszClientAddr, TCHAR * ptszMsgBuffer, int* pInt_MsgLen) { - return m_DLStorage.Session_DLStroage_GetList(nPool, nIndex, ptszClientAddr, ptszMsgBuffer, pInt_MsgLen); + return m_DLStorage.Session_DLStroage_GetList(nPool, lpszClientAddr, ptszMsgBuffer, pInt_MsgLen); } -extern "C" BOOL Session_DLStroage_GetInfo(int nPool, int nIndex, SESSION_STORAGEINFO * pSt_StorageInfo) +extern "C" BOOL Session_DLStroage_GetInfo(int nPool, LPCTSTR lpszClientAddr, SESSION_STORAGEINFO * pSt_StorageInfo) { - return m_DLStorage.Session_DLStroage_GetInfo(nPool, nIndex, pSt_StorageInfo); + return m_DLStorage.Session_DLStroage_GetInfo(nPool, lpszClientAddr, pSt_StorageInfo); } -extern "C" BOOL Session_DLStroage_GetCount(int nIndex, int* pInt_ListCount) +extern "C" BOOL Session_DLStroage_GetCount(int nIndex, list*pStl_ListClient) { - return m_DLStorage.Session_DLStroage_GetCount(nIndex, pInt_ListCount); + return m_DLStorage.Session_DLStroage_GetCount(nIndex, pStl_ListClient); } -extern "C" BOOL Session_DLStorage_SetSeek(LPCTSTR lpszClientAddr, int nSeek) +extern "C" BOOL Session_DLStorage_SetSeek(LPCTSTR lpszClientAddr, int nSeek, BOOL bError, SESSION_STORAGEDYNAMICRATE * pSt_StorageRate) { - return m_DLStorage.Session_DLStorage_SetSeek(lpszClientAddr, nSeek); + return m_DLStorage.Session_DLStorage_SetSeek(lpszClientAddr, nSeek, bError, pSt_StorageRate); } extern "C" BOOL Session_DLStroage_Delete(LPCTSTR lpszClientAddr) { diff --git a/XEngine_Source/StorageModule_Session/pch.h b/XEngine_Source/StorageModule_Session/pch.h index 97bdb0a..e22d22f 100644 --- a/XEngine_Source/StorageModule_Session/pch.h +++ b/XEngine_Source/StorageModule_Session/pch.h @@ -30,6 +30,8 @@ using namespace std; #include #include #include +#include +#include #include "Session_Define.h" #include "Session_Error.h" /******************************************************************** @@ -50,4 +52,12 @@ extern DWORD Session_dwErrorCode; typedef std::wstring tstring; #else typedef std::string tstring; +#endif + +#ifdef _WINDOWS +#ifdef _WIN64 +#pragma comment(lib,"x64/XEngine_BaseLib/XEngine_BaseLib.lib") +#else +#pragma comment(lib,"x86/XEngine_BaseLib/XEngine_BaseLib.lib") +#endif #endif \ No newline at end of file diff --git a/XEngine_Source/XEngine_StorageApp/Makefile b/XEngine_Source/XEngine_StorageApp/Makefile index 6339fcf..6605d85 100644 --- a/XEngine_Source/XEngine_StorageApp/Makefile +++ b/XEngine_Source/XEngine_StorageApp/Makefile @@ -5,7 +5,7 @@ LOADBIN = -L /usr/local/lib/XEngine_Release/XEngine_BaseLib -L /usr/local/lib/XE LIB = -lXEngine_BaseLib -lXEngine_Algorithm -lXEngine_Core -lXEngine_ManagePool -lXEngine_NetXApi -lXEngine_OPenSsl -lHelpComponents_XLog -lHelpComponents_Packets -lXEngine_ProcSdk -lXEngine_SystemApi -lRfcComponents_HttpServer -lNetHelp_APIHelp -lXStorage_SQLPacket -lXStorage_Protocol -lXEngine_P2XPPeer -lXEngine_P2XPProtocol -lStorageModule_Config -lStorageModule_Session -lStorageModule_APIHelp LIBEX = -static-libgcc -ldl -lrt -lpthread LOADSO = -Wl,-rpath=./,--disable-new-dtags -LIBINCLUDE = StorageApp_Config.o StorageApp_Download.o StorageApp_Network.o StorageApp_Center.o StorageApp_UPLoader.o StorageApp_P2XPNet.o Storage_APPHelp.o Storage_TaskEvent.o Storage_TaskPass.o Storage_TaskQuery.o Storage_TaskManage.o Storage_TaskP2p.o XEngine_StorageApp.o +LIBINCLUDE = StorageApp_Config.o StorageApp_Download.o StorageApp_Network.o StorageApp_Center.o StorageApp_UPLoader.o StorageApp_P2XPNet.o Storage_APPHelp.o Storage_TaskEvent.o Storage_TaskPass.o Storage_TaskManage.o Storage_TaskP2p.o XEngine_StorageApp.o ifeq ($(RELEASE),1) FLAGS = -c -O2 @@ -44,8 +44,6 @@ Storage_TaskEvent.o:./Storage_APPTask/Storage_TaskEvent.cpp $(CC) $(DEBUG) $(FLAGS) $(UNICODE) ./Storage_APPTask/Storage_TaskEvent.cpp Storage_TaskPass.o:./Storage_APPTask/Storage_TaskPass.cpp $(CC) $(DEBUG) $(FLAGS) $(UNICODE) ./Storage_APPTask/Storage_TaskPass.cpp -Storage_TaskQuery.o:./Storage_APPTask/Storage_TaskQuery.cpp - $(CC) $(DEBUG) $(FLAGS) $(UNICODE) ./Storage_APPTask/Storage_TaskQuery.cpp Storage_TaskManage.o:./Storage_APPTask/Storage_TaskManage.cpp $(CC) $(DEBUG) $(FLAGS) $(UNICODE) ./Storage_APPTask/Storage_TaskManage.cpp Storage_TaskP2p.o:./Storage_APPTask/Storage_TaskP2p.cpp diff --git a/XEngine_Source/XEngine_StorageApp/StorageApp_Center.cpp b/XEngine_Source/XEngine_StorageApp/StorageApp_Center.cpp index 82df8e8..38369fb 100644 --- a/XEngine_Source/XEngine_StorageApp/StorageApp_Center.cpp +++ b/XEngine_Source/XEngine_StorageApp/StorageApp_Center.cpp @@ -57,6 +57,8 @@ BOOL XEngine_Task_HttpCenter(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int LPCTSTR lpszMethodPost = _T("POST"); LPCTSTR lpszMethodGet = _T("GET"); + LPCTSTR lpszMethodOption = _T("OPTIONS"); + if (0 == _tcsnicmp(lpszMethodPost, pSt_HTTPParam->tszHttpMethod, _tcslen(lpszMethodPost))) { if (!XEngine_APPHelp_ProxyAuth(lpszClientAddr, lpszMethodPost, pSt_HTTPParam->tszHttpUri, pptszListHdr, nHdrCount, STORAGE_NETTYPE_HTTPCENTER)) @@ -103,10 +105,6 @@ BOOL XEngine_Task_HttpCenter(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int { XEngine_Task_Pass(tszAPIName, lpszClientAddr, lpszMsgBuffer, nMsgLen, pSt_HTTPParam, pptszListHdr, nHdrCount); } - else if (0 == _tcsnicmp(XENGINE_STORAGE_APP_TASK_QUERY, tszAPIMethod, _tcslen(XENGINE_STORAGE_APP_TASK_QUERY))) - { - XEngine_Task_Query(tszAPIName, lpszClientAddr, lpszMsgBuffer, nMsgLen, pSt_HTTPParam, pptszListHdr, nHdrCount); - } else if (0 == _tcsnicmp(XENGINE_STORAGE_APP_TASK_EVENT, tszAPIMethod, _tcslen(XENGINE_STORAGE_APP_TASK_EVENT))) { XEngine_Task_Event(tszAPIName, lpszClientAddr, lpszMsgBuffer, nMsgLen, pSt_HTTPParam, pptszListHdr, nHdrCount); @@ -128,6 +126,16 @@ BOOL XEngine_Task_HttpCenter(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int } XEngine_Task_P2PGet(pSt_HTTPParam->tszHttpUri + 1, lpszClientAddr, pSt_HTTPParam); } + else if (0 == _tcsnicmp(lpszMethodOption, pSt_HTTPParam->tszHttpMethod, _tcslen(lpszMethodOption))) + { + //用于心跳 + st_HDRParam.bIsClose = TRUE; + st_HDRParam.nHttpCode = 200; + LPCTSTR lpszHdrBuffer = _T("Allow: POST OPTIONS\r\n"); + RfcComponents_HttpServer_SendMsgEx(xhCenterHttp, tszSDBuffer, &nSDLen, &st_HDRParam, NULL, 0, lpszHdrBuffer); + XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_HTTPCENTER); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("业务客户端:%s,请求OPTIONS心跳方法成功"), lpszClientAddr); + } else { st_HDRParam.bIsClose = TRUE; diff --git a/XEngine_Source/XEngine_StorageApp/StorageApp_Center.h b/XEngine_Source/XEngine_StorageApp/StorageApp_Center.h index fb7d194..0e271a5 100644 --- a/XEngine_Source/XEngine_StorageApp/StorageApp_Center.h +++ b/XEngine_Source/XEngine_StorageApp/StorageApp_Center.h @@ -1,16 +1,12 @@ #pragma once #define XENGINE_STORAGE_APP_TASK_EVENT _T("Event") -#define XENGINE_STORAGE_APP_TASK_QUERY _T("Query") #define XENGINE_STORAGE_APP_TASK_PASS _T("Pass") #define XENGINE_STORAGE_APP_TASK_MANAGE _T("Manage") #define XENGINE_STORAGE_APP_METHOD_CONFIG _T("Config") #define XENGINE_STORAGE_APP_METHOD_UPFILE _T("UPFile") #define XENGINE_STORAGE_APP_METHOD_DLFILE _T("DLFile") -#define XENGINE_STORAGE_APP_METHOD_FILE _T("File") -#define XENGINE_STORAGE_APP_METHOD_ADD _T("Add") -#define XENGINE_STORAGE_APP_METHOD_DEL _T("Del") XHTHREAD CALLBACK XEngine_Center_HTTPThread(LPVOID lParam); BOOL XEngine_Task_HttpCenter_APIList(LPCTSTR lpszUrlName, TCHAR* ptszAPIVersion, TCHAR* ptszAPIMethod, TCHAR* ptszAPIName); diff --git a/XEngine_Source/XEngine_StorageApp/StorageApp_Download.cpp b/XEngine_Source/XEngine_StorageApp/StorageApp_Download.cpp index c22596a..cd8017c 100644 --- a/XEngine_Source/XEngine_StorageApp/StorageApp_Download.cpp +++ b/XEngine_Source/XEngine_StorageApp/StorageApp_Download.cpp @@ -44,22 +44,21 @@ XHTHREAD CALLBACK XEngine_Download_HTTPThread(LPVOID lParam) XHTHREAD CALLBACK XEngine_Download_SendThread(LPVOID lParam) { int nThreadPos = *(int*)lParam; - TCHAR tszClientAddr[128]; TCHAR tszMsgBuffer[4096]; while (bIsRun) { - int nListCount = 0; - memset(tszClientAddr, '\0', sizeof(tszClientAddr)); + list stl_ListClient; memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer)); - Session_DLStroage_GetCount(nThreadPos, &nListCount); - for (int i = 0; i < nListCount; i++) + Session_DLStroage_GetCount(nThreadPos, &stl_ListClient); + list::const_iterator stl_ListIterator = stl_ListClient.begin(); + for (; stl_ListIterator != stl_ListClient.end(); stl_ListIterator++) { int nMsgLen = 4096; - if (!Session_DLStroage_GetList(nThreadPos, i, tszClientAddr, tszMsgBuffer, &nMsgLen)) + if (!Session_DLStroage_GetList(nThreadPos, stl_ListIterator->c_str(), tszMsgBuffer, &nMsgLen)) { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("下载客户端:%s,获取用户对应文件内容失败,错误:%lX"), tszClientAddr, Session_GetLastError()); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("下载客户端:%s,获取用户对应文件内容失败,错误:%lX"), stl_ListIterator->c_str(), Session_GetLastError()); continue; } if (nMsgLen <= 0) @@ -80,23 +79,21 @@ XHTHREAD CALLBACK XEngine_Download_SendThread(LPVOID lParam) OPenSsl_Api_Digest(st_StorageInfo.tszFileDir, tszHashKey, NULL, TRUE, st_ServiceCfg.st_XStorage.nHashMode); BaseLib_OperatorString_StrToHex((char*)tszHashKey, 20, tszHashStr); - Session_DLStroage_GetInfo(nThreadPos, i, &st_StorageInfo); + Session_DLStroage_GetInfo(nThreadPos, stl_ListIterator->c_str(), &st_StorageInfo); XStorageProtocol_Proxy_PacketUPDown(st_StorageInfo.tszFileDir, st_StorageInfo.tszClientAddr, st_StorageInfo.ullRWCount, tszProxyStr, &nPLen, tszHashStr); APIHelp_HttpRequest_Post(st_ServiceCfg.st_XProxy.st_XProxyPass.tszDLPass, tszProxyStr, &nHttpCode); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_NOTICE, _T("下载客户端:%s,请求完成通知返回值:%d,文件:%s,地址:%s"), tszClientAddr, nHttpCode, st_StorageInfo.tszFileDir, st_ServiceCfg.st_XProxy.st_XProxyPass.tszDLPass); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_NOTICE, _T("下载客户端:%s,请求完成通知返回值:%d,文件:%s,地址:%s"), stl_ListIterator->c_str(), nHttpCode, st_StorageInfo.tszFileDir, st_ServiceCfg.st_XProxy.st_XProxyPass.tszDLPass); } - Session_DLStroage_Delete(tszClientAddr); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_NOTICE, _T("下载客户端:%s,文件已经发送完毕,用户已经被移除发送列表"), tszClientAddr); + Session_DLStroage_Delete(stl_ListIterator->c_str()); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_NOTICE, _T("下载客户端:%s,文件已经发送完毕,用户已经被移除发送列表"), stl_ListIterator->c_str()); continue; } - XEngine_Task_SendDownload(tszClientAddr, tszMsgBuffer, nMsgLen); + XEngine_Task_SendDownload(stl_ListIterator->c_str(), tszMsgBuffer, nMsgLen); } int nTimeWait = 1; -#ifdef _WINDOWS - st_ServiceCfg.st_XLimit.nMaxDNLoader = st_ServiceCfg.st_XLimit.nMaxDNLoader * 10; -#endif - Algorithm_Calculation_SleepFlow(&nTimeWait, st_ServiceCfg.st_XLimit.nMaxDNLoader, nListCount, 4096); + Algorithm_Calculation_SleepFlow(&nTimeWait, st_ServiceCfg.st_XLimit.nMaxDNLoader, stl_ListClient.size(), 4096); + stl_ListClient.clear(); std::this_thread::sleep_for(std::chrono::microseconds(nTimeWait)); } return 0; @@ -202,14 +199,17 @@ BOOL XEngine_Task_SendDownload(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, in } else { - if (Session_DLStorage_SetSeek(lpszClientAddr, -nMsgLen)) + SESSION_STORAGEDYNAMICRATE st_StorageRate; + memset(&st_StorageRate, '\0', sizeof(SESSION_STORAGEDYNAMICRATE)); + + if (Session_DLStorage_SetSeek(lpszClientAddr, -nMsgLen, TRUE, &st_StorageRate)) { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _T("下载客户端:%s,正在发送文件数据,发送失败,移动指针:%d"), lpszClientAddr, -nMsgLen); + 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); } else { XEngine_Net_CloseClient(lpszClientAddr, STORAGE_LEAVETYPE_CLOSE, STORAGE_NETTYPE_HTTPDOWNLOAD); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("下载客户端:%s,正在发送文件数据,大小:%d,发送超过重试次数,无法继续,移除发送队列"), lpszClientAddr, nMsgLen); + 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); } } return TRUE; diff --git a/XEngine_Source/XEngine_StorageApp/StorageApp_Hdr.h b/XEngine_Source/XEngine_StorageApp/StorageApp_Hdr.h index a187a2e..17dae05 100644 --- a/XEngine_Source/XEngine_StorageApp/StorageApp_Hdr.h +++ b/XEngine_Source/XEngine_StorageApp/StorageApp_Hdr.h @@ -43,6 +43,10 @@ using namespace std; #include #include #include +#include +#include +#include +#include #ifdef _UNICODE typedef std::wstring tstring; @@ -112,7 +116,6 @@ extern XENGINE_LBCONFIG st_LoadbalanceCfg; #include "StorageApp_P2XPNet.h" #include "Storage_APPTask/Storage_TaskEvent.h" #include "Storage_APPTask/Storage_TaskPass.h" -#include "Storage_APPTask/Storage_TaskQuery.h" #include "Storage_APPTask/Storage_TaskP2p.h" #include "Storage_APPTask/Storage_TaskManage.h" #include "Storage_APPHelp/Storage_APPHelp.h" @@ -137,6 +140,7 @@ extern XENGINE_LBCONFIG st_LoadbalanceCfg; #pragma comment(lib,"x64/XEngine_HelpComponents/HelpComponents_Packets.lib") #pragma comment(lib,"x64/XEngine_RfcComponents/RfcComponents_HttpServer.lib") #pragma comment(lib,"x64/XEngine_NetHelp/NetHelp_APIHelp.lib") +#pragma comment(lib,"x64/XEngine_SystemSdk/XEngine_SystemApi.lib") #else #ifdef _DEBUG #pragma comment(lib,"../Debug/StorageModule_Session.lib") @@ -165,6 +169,7 @@ extern XENGINE_LBCONFIG st_LoadbalanceCfg; #pragma comment(lib,"x86/XEngine_HelpComponents/HelpComponents_Packets.lib") #pragma comment(lib,"x86/XEngine_RfcComponents/RfcComponents_HttpServer.lib") #pragma comment(lib,"x86/XEngine_NetHelp/NetHelp_APIHelp.lib") +#pragma comment(lib,"x86/XEngine_SystemSdk/XEngine_SystemApi.lib") #endif #else diff --git a/XEngine_Source/XEngine_StorageApp/StorageApp_Network.cpp b/XEngine_Source/XEngine_StorageApp/StorageApp_Network.cpp index fdb96a8..89a7a88 100644 --- a/XEngine_Source/XEngine_StorageApp/StorageApp_Network.cpp +++ b/XEngine_Source/XEngine_StorageApp/StorageApp_Network.cpp @@ -163,38 +163,48 @@ BOOL XEngine_Net_SendMsg(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int nMsg if (STORAGE_NETTYPE_HTTPDOWNLOAD == nType) { +#if ((XENGINE_VERSION_KERNEL >= 7) && (XENGINE_VERSION_MAIN > 18)) + bRet = NetCore_TCPXCore_SendEx(xhNetDownload, lpszClientAddr, lpszMsgBuffer, nMsgLen, 0, 10); +#else bRet = NetCore_TCPXCore_SendEx(xhNetDownload, lpszClientAddr, lpszMsgBuffer, nMsgLen); +#endif if (bRet && st_ServiceCfg.st_XTime.bHBTime) { SocketOpt_HeartBeat_ActiveAddrEx(xhHBDownload, lpszClientAddr); } - } - else if (STORAGE_NETTYPE_HTTPUPLOADER == nType) - { - bRet = NetCore_TCPXCore_SendEx(xhNetUPLoader, lpszClientAddr, lpszMsgBuffer, nMsgLen); - if (bRet && st_ServiceCfg.st_XTime.bHBTime) + if (!bRet) { - SocketOpt_HeartBeat_ActiveAddrEx(xhHBUPLoader, lpszClientAddr); + return FALSE; } } - else if (STORAGE_NETTYPE_HTTPCENTER == nType) - { - bRet = NetCore_TCPXCore_SendEx(xhNetCenter, lpszClientAddr, lpszMsgBuffer, nMsgLen); - } - else if (STORAGE_NETTYPE_TCPP2XP == nType) + else { - bRet = NetCore_TCPXCore_SendEx(xhNetP2xp, lpszClientAddr, lpszMsgBuffer, nMsgLen); - if (bRet && st_ServiceCfg.st_XTime.bHBTime) + if (STORAGE_NETTYPE_HTTPUPLOADER == nType) { - SocketOpt_HeartBeat_ActiveAddrEx(xhHBP2xp, lpszClientAddr); + bRet = NetCore_TCPXCore_SendEx(xhNetUPLoader, lpszClientAddr, lpszMsgBuffer, nMsgLen); + if (bRet && st_ServiceCfg.st_XTime.bHBTime) + { + SocketOpt_HeartBeat_ActiveAddrEx(xhHBUPLoader, lpszClientAddr); + } + } + else if (STORAGE_NETTYPE_HTTPCENTER == nType) + { + bRet = NetCore_TCPXCore_SendEx(xhNetCenter, lpszClientAddr, lpszMsgBuffer, nMsgLen); + } + else if (STORAGE_NETTYPE_TCPP2XP == nType) + { + bRet = NetCore_TCPXCore_SendEx(xhNetP2xp, lpszClientAddr, lpszMsgBuffer, nMsgLen); + if (bRet && st_ServiceCfg.st_XTime.bHBTime) + { + SocketOpt_HeartBeat_ActiveAddrEx(xhHBP2xp, lpszClientAddr); + } + } + if (!bRet) + { + DWORD dwRet = NetCore_GetLastError(); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("客户端:%s,网络类型:%d,发送数据失败,发送大小:%d,错误:%lX,%d"), lpszClientAddr, nType, nMsgLen, dwRet, errno); + return FALSE; } - } - - if (!bRet) - { - DWORD dwRet = NetCore_GetLastError(); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("客户端:%s,网络类型:%d,发送数据失败,发送大小:%d,错误:%lX,%d"), lpszClientAddr, nType, nMsgLen, dwRet, errno); - return FALSE; } return TRUE; } diff --git a/XEngine_Source/XEngine_StorageApp/StorageApp_UPLoader.cpp b/XEngine_Source/XEngine_StorageApp/StorageApp_UPLoader.cpp index d7e86b7..5964e61 100644 --- a/XEngine_Source/XEngine_StorageApp/StorageApp_UPLoader.cpp +++ b/XEngine_Source/XEngine_StorageApp/StorageApp_UPLoader.cpp @@ -192,7 +192,7 @@ BOOL XEngine_Task_HttpUPLoader(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, in else { _stprintf(tszFileDir, _T("%s%s"), st_ServiceCfg.st_XStorage.tszFileDir, pSt_HTTPParam->tszHttpUri); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("上传客户端:%s,请求上传文件中,文件名:%s,大小:%d"), lpszClientAddr, tszFileDir, nMsgLen); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_DEBUG, _T("上传客户端:%s,请求上传文件中,文件名:%s,大小:%d"), lpszClientAddr, tszFileDir, nMsgLen); } return TRUE; diff --git a/XEngine_Source/XEngine_StorageApp/Storage_APPHelp/Storage_APPHelp.cpp b/XEngine_Source/XEngine_StorageApp/Storage_APPHelp/Storage_APPHelp.cpp index f621e09..5a318d7 100644 --- a/XEngine_Source/XEngine_StorageApp/Storage_APPHelp/Storage_APPHelp.cpp +++ b/XEngine_Source/XEngine_StorageApp/Storage_APPHelp/Storage_APPHelp.cpp @@ -133,11 +133,16 @@ BOOL XEngine_APPHelp_RangeFile(LPCTSTR lpszClientAddr, int* pInt_SPos, int* pInt //是否有范围 if (!RfcComponents_HttpHelp_GetField(&pptszListHdr, nHdrCount, lpszRange, tszRangeStr)) { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _T("%s:%s,请求内容没有范围信息"), lpszClientType, lpszClientAddr); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("%s:%s,请求内容没有范围信息"), lpszClientType, lpszClientAddr); return FALSE; } //是否没有找到 - if (!BaseLib_OperatorString_GetWithChar(tszRangeStr, tszKeyStr, tszValueStr, '-')) + int nBPos = 0; //某些时候有个BYTE + if (NULL != _tcsstr(tszRangeStr,_T("bytes="))) + { + nBPos = 6; + } + if (!BaseLib_OperatorString_GetWithChar(tszRangeStr + nBPos, tszKeyStr, tszValueStr, '-')) { XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("%s:%s,请求内容有范围信息,但是解析失败,内容:%s"), lpszClientType, lpszClientAddr, tszRangeStr); return FALSE; diff --git a/XEngine_Source/XEngine_StorageApp/Storage_APPTask/Storage_TaskManage.cpp b/XEngine_Source/XEngine_StorageApp/Storage_APPTask/Storage_TaskManage.cpp index f7a6951..3fbc3e9 100644 --- a/XEngine_Source/XEngine_StorageApp/Storage_APPTask/Storage_TaskManage.cpp +++ b/XEngine_Source/XEngine_StorageApp/Storage_APPTask/Storage_TaskManage.cpp @@ -4,10 +4,13 @@ BOOL XEngine_Task_Manage(LPCTSTR lpszAPIName, LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int nMsgLen, RFCCOMPONENTS_HTTP_REQPARAM* pSt_HTTPParam, TCHAR** pptszListHdr, int nHdrCount) { int nSDLen = 2048; + int nRVLen = 2048; TCHAR tszSDBuffer[2048]; + TCHAR tszRVBuffer[2048]; RFCCOMPONENTS_HTTP_HDRPARAM st_HDRParam; memset(tszSDBuffer, '\0', sizeof(tszSDBuffer)); + memset(tszRVBuffer, '\0', sizeof(tszRVBuffer)); memset(&st_HDRParam, '\0', sizeof(RFCCOMPONENTS_HTTP_HDRPARAM)); //文件存储成功的事件上传 @@ -163,5 +166,121 @@ BOOL XEngine_Task_Manage(LPCTSTR lpszAPIName, LPCTSTR lpszClientAddr, LPCTSTR lp XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_HTTPCENTER); BaseLib_OperatorMemory_Free((XPPPMEM)&ppSt_DBFile, nListCount); } + else if (0 == _tcsnicmp(XENGINE_STORAGE_APP_METHOD_QUERYFILE, lpszAPIName, _tcslen(XENGINE_STORAGE_APP_METHOD_QUERYFILE))) + { + //查询文件列表 + int nMsgLen = 10240; + TCHAR tszFileName[MAX_PATH]; + TCHAR tszFileHash[MAX_PATH]; + TCHAR tszTimeStart[128]; + TCHAR tszTimeEnd[128]; + TCHAR tszMsgBuffer[10240]; + + memset(tszFileName, '\0', MAX_PATH); + memset(tszFileHash, '\0', MAX_PATH); + memset(tszTimeStart, '\0', sizeof(tszTimeStart)); + memset(tszTimeEnd, '\0', sizeof(tszTimeEnd)); + memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer)); + + int nListCount = 0; + XSTORAGECORE_DBFILE** ppSt_ListFile; + XStorageProtocol_Core_REQQueryFile(lpszMsgBuffer, tszTimeStart, tszTimeEnd, tszFileHash); + + if (0 == st_ServiceCfg.st_XSql.nSQLType) + { + st_HDRParam.bIsClose = TRUE; + st_HDRParam.nHttpCode = 406; + + RfcComponents_HttpServer_SendMsgEx(xhCenterHttp, tszSDBuffer, &nSDLen, &st_HDRParam); + XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_HTTPCENTER); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _T("业务客户端:%s,请求查询文件列表失败,服务器没有启用这个功能"), lpszClientAddr); + } + else + { + if (1 == st_ServiceCfg.st_XSql.nSQLType) + { + XStorageSQL_File_FileQuery(&ppSt_ListFile, &nListCount, tszTimeStart, tszTimeEnd, tszFileName, tszFileHash); + } + else + { + XStorage_SQLite_FileQuery(&ppSt_ListFile, &nListCount, tszTimeStart, tszTimeEnd, tszFileName, tszFileHash); + } + st_HDRParam.bIsClose = TRUE; + st_HDRParam.nHttpCode = 200; + + XStorageProtocol_Core_REPQueryFile(tszMsgBuffer, &nMsgLen, &ppSt_ListFile, nListCount, st_ServiceCfg.st_XStorage.tszFileDir, tszTimeStart, tszTimeEnd); + RfcComponents_HttpServer_SendMsgEx(xhCenterHttp, tszSDBuffer, &nSDLen, &st_HDRParam, tszMsgBuffer, nMsgLen); + XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_HTTPCENTER); + BaseLib_OperatorMemory_Free((XPPPMEM)&ppSt_ListFile, nListCount); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("业务客户端:%s,请求查询文件列表成功,列表个数:%d"), lpszClientAddr, nListCount); + } + } + else if (0 == _tcsnicmp(XENGINE_STORAGE_APP_METHOD_DIR, lpszAPIName, _tcslen(XENGINE_STORAGE_APP_METHOD_DIR))) + { + int nOPCode = 0; + int nListCount = 0; + CHAR** ppszListDir = NULL; + TCHAR tszUserDir[MAX_PATH]; + TCHAR tszRealDir[1024]; + + memset(tszUserDir, '\0', MAX_PATH); + memset(tszRealDir, '\0', sizeof(tszRealDir)); + + st_HDRParam.bIsClose = TRUE; + st_HDRParam.nHttpCode = 200; + + XStorageProtocol_Core_REQDirOperator(lpszMsgBuffer, tszUserDir, &nOPCode); + _stprintf(tszRealDir, _T("%s/%s"), st_ServiceCfg.st_XStorage.tszFileDir, tszUserDir); + if (0 == nOPCode) + { + if (!SystemApi_File_EnumFile(tszRealDir, &ppszListDir, &nListCount, NULL, NULL, TRUE, 2)) + { + st_HDRParam.bIsClose = TRUE; + st_HDRParam.nHttpCode = 404; + + RfcComponents_HttpServer_SendMsgEx(xhCenterHttp, tszSDBuffer, &nSDLen, &st_HDRParam); + XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_HTTPCENTER); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("业务客户端:%s,请求查询文件夹:%s,失败,错误:%lX"), lpszClientAddr, tszRealDir, SystemApi_GetLastError()); + return FALSE; + } + XStorageProtocol_Core_REPDirOperator(tszRVBuffer, &nRVLen, &ppszListDir, nListCount); + BaseLib_OperatorMemory_Free((XPPPMEM)&ppszListDir, nListCount); + RfcComponents_HttpServer_SendMsgEx(xhCenterHttp, tszSDBuffer, &nSDLen, &st_HDRParam, tszRVBuffer, nRVLen); + XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_HTTPCENTER); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("业务客户端:%s,请求查询文件夹:%s,成功,文件夹个数:%d"), lpszClientAddr, tszRealDir, nListCount); + } + else if (1 == nOPCode) + { + if (!SystemApi_File_CreateMutilFolder(tszRealDir)) + { + st_HDRParam.bIsClose = TRUE; + st_HDRParam.nHttpCode = 404; + + RfcComponents_HttpServer_SendMsgEx(xhCenterHttp, tszSDBuffer, &nSDLen, &st_HDRParam); + XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_HTTPCENTER); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("业务客户端:%s,请求创建文件夹:%s,失败,错误:%lX"), lpszClientAddr, tszRealDir, SystemApi_GetLastError()); + return FALSE; + } + RfcComponents_HttpServer_SendMsgEx(xhCenterHttp, tszSDBuffer, &nSDLen, &st_HDRParam); + XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_HTTPCENTER); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("业务客户端:%s,请求创建文件夹:%s,成功"), lpszClientAddr, tszRealDir); + } + else if (2 == nOPCode) + { + if (!SystemApi_File_DeleteMutilFolder(tszRealDir)) + { + st_HDRParam.bIsClose = TRUE; + st_HDRParam.nHttpCode = 404; + + RfcComponents_HttpServer_SendMsgEx(xhCenterHttp, tszSDBuffer, &nSDLen, &st_HDRParam); + XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_HTTPCENTER); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("业务客户端:%s,请求删除文件夹:%s,失败,错误:%lX"), lpszClientAddr, tszRealDir, SystemApi_GetLastError()); + return FALSE; + } + RfcComponents_HttpServer_SendMsgEx(xhCenterHttp, tszSDBuffer, &nSDLen, &st_HDRParam); + XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_HTTPCENTER); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("业务客户端:%s,请求删除文件夹:%s,成功"), lpszClientAddr, tszRealDir); + } + } return TRUE; } \ No newline at end of file diff --git a/XEngine_Source/XEngine_StorageApp/Storage_APPTask/Storage_TaskManage.h b/XEngine_Source/XEngine_StorageApp/Storage_APPTask/Storage_TaskManage.h index b1b3ac3..f67137a 100644 --- a/XEngine_Source/XEngine_StorageApp/Storage_APPTask/Storage_TaskManage.h +++ b/XEngine_Source/XEngine_StorageApp/Storage_APPTask/Storage_TaskManage.h @@ -1,3 +1,8 @@ #pragma once +#define XENGINE_STORAGE_APP_METHOD_ADD _T("Add") +#define XENGINE_STORAGE_APP_METHOD_DEL _T("Del") +#define XENGINE_STORAGE_APP_METHOD_QUERYFILE _T("Query") +#define XENGINE_STORAGE_APP_METHOD_DIR _T("Dir") + BOOL XEngine_Task_Manage(LPCTSTR lpszAPIName, LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int nMsgLen, RFCCOMPONENTS_HTTP_REQPARAM* pSt_HTTPParam, TCHAR** pptszListHdr, int nHdrCount); \ No newline at end of file diff --git a/XEngine_Source/XEngine_StorageApp/Storage_APPTask/Storage_TaskP2p.cpp b/XEngine_Source/XEngine_StorageApp/Storage_APPTask/Storage_TaskP2p.cpp index 65c4e3b..c388f1c 100644 --- a/XEngine_Source/XEngine_StorageApp/Storage_APPTask/Storage_TaskP2p.cpp +++ b/XEngine_Source/XEngine_StorageApp/Storage_APPTask/Storage_TaskP2p.cpp @@ -40,7 +40,7 @@ XHTHREAD XEngine_Task_P2PThread() if (nListCount > 0) { _stprintf(pppSt_ListFile[0]->tszTableName, _T("%s:%d"), st_ServiceCfg.tszIPAddr, st_ServiceCfg.nStorageDLPort); - XStorageProtocol_Core_REPQueryFile(tszMsgBuffer, &nMsgLen, &pppSt_ListFile, nListCount, tszTimeStart, tszTimeEnd); + XStorageProtocol_Core_REPQueryFile(tszMsgBuffer, &nMsgLen, &pppSt_ListFile, nListCount, st_ServiceCfg.st_XStorage.tszFileDir, tszTimeStart, tszTimeEnd); BaseLib_OperatorMemory_Free((XPPPMEM)&pppSt_ListFile, nListCount); SOCKET hSDSocket; @@ -87,8 +87,8 @@ BOOL XEngine_Task_P2PGet(LPCTSTR lpszFileHash, LPCTSTR lpszClientAddr, RFCCOMPON st_HDRParam.bIsClose = TRUE; st_HDRParam.nHttpCode = 200; - _stprintf(pppSt_ListFile[0]->tszTableName, _T("127.0.0.1")); - XStorageProtocol_Core_REPQueryFile(tszRVBuffer, &nRVLen, &pppSt_ListFile, nListCount); + _stprintf(pppSt_ListFile[0]->tszTableName, _T("127.0.0.1:%d"), st_ServiceCfg.nStorageDLPort); + XStorageProtocol_Core_REPQueryFile(tszRVBuffer, &nRVLen, &pppSt_ListFile, nListCount, st_ServiceCfg.st_XStorage.tszFileDir); BaseLib_OperatorMemory_Free((XPPPMEM)&pppSt_ListFile, nListCount); RfcComponents_HttpServer_SendMsgEx(xhCenterHttp, tszMsgBuffer, &nMsgLen, &st_HDRParam, tszRVBuffer, nRVLen); @@ -121,8 +121,15 @@ BOOL XEngine_Task_P2PGet(LPCTSTR lpszFileHash, LPCTSTR lpszClientAddr, RFCCOMPON else { //开始广播请求文件 + SOCKET hSDSocket; + SOCKET hRVSocket; + list stl_ListFile; + XStorageProtocol_Client_REQQueryFile(tszSDBuffer, &nSDLen, NULL, lpszFileHash); - if (!NetCore_BroadCast_Send(hBroadSocket, tszSDBuffer, nSDLen)) + NetCore_BroadCast_SendInit(&hSDSocket, st_ServiceCfg.st_P2xp.nRVPort, st_ServiceCfg.tszIPAddr); + NetCore_BroadCast_RecvInit(&hRVSocket, st_ServiceCfg.st_P2xp.nSDPort); + + if (!NetCore_BroadCast_Send(hSDSocket, tszSDBuffer, nSDLen)) { st_HDRParam.bIsClose = TRUE; st_HDRParam.nHttpCode = 500; @@ -132,10 +139,8 @@ BOOL XEngine_Task_P2PGet(LPCTSTR lpszFileHash, LPCTSTR lpszClientAddr, RFCCOMPON XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("广播端:%s,发送广播请求失败,错误:%lX"), lpszClientAddr, NetCore_GetLastError()); return FALSE; } - - SOCKET hRVSocket; - list stl_ListFile; - NetCore_BroadCast_RecvInit(&hRVSocket, st_ServiceCfg.st_P2xp.nSDPort); + NetCore_BroadCast_Close(hSDSocket); + time_t nTimeStart = time(NULL); while (1) { @@ -170,7 +175,7 @@ BOOL XEngine_Task_P2PGet(LPCTSTR lpszFileHash, LPCTSTR lpszClientAddr, RFCCOMPON int nListCount = 0; XSTORAGECORE_DBFILE** ppSt_ListPacket; APIHelp_Distributed_FileList(&stl_ListFile, &ppSt_ListPacket, &nListCount); - XStorageProtocol_Core_REPQueryFile(tszRVBuffer, &nRVLen, &ppSt_ListPacket, nListCount); + XStorageProtocol_Core_REPQueryFile(tszRVBuffer, &nRVLen, &ppSt_ListPacket, nListCount, st_ServiceCfg.st_XStorage.tszFileDir); RfcComponents_HttpServer_SendMsgEx(xhCenterHttp, tszMsgBuffer, &nMsgLen, &st_HDRParam, tszRVBuffer, nRVLen); BaseLib_OperatorMemory_Free((XPPPMEM)&ppSt_ListPacket, nListCount); } diff --git a/XEngine_Source/XEngine_StorageApp/Storage_APPTask/Storage_TaskQuery.cpp b/XEngine_Source/XEngine_StorageApp/Storage_APPTask/Storage_TaskQuery.cpp deleted file mode 100644 index ba12e1b..0000000 --- a/XEngine_Source/XEngine_StorageApp/Storage_APPTask/Storage_TaskQuery.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "../StorageApp_Hdr.h" - -BOOL XEngine_Task_Query(LPCTSTR lpszAPIName, LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int nMsgLen, RFCCOMPONENTS_HTTP_REQPARAM* pSt_HTTPParam, TCHAR** pptszListHdr, int nHdrCount) -{ - int nSDLen = 2048; - TCHAR tszSDBuffer[2048]; - RFCCOMPONENTS_HTTP_HDRPARAM st_HDRParam; - - memset(tszSDBuffer, '\0', sizeof(tszSDBuffer)); - memset(&st_HDRParam, '\0', sizeof(RFCCOMPONENTS_HTTP_HDRPARAM)); - - //文件查询类型 - if (0 == _tcsnicmp(XENGINE_STORAGE_APP_METHOD_FILE, lpszAPIName, _tcslen(XENGINE_STORAGE_APP_METHOD_FILE))) - { - //查询文件列表 - int nMsgLen = 10240; - TCHAR tszFileName[MAX_PATH]; - TCHAR tszFileHash[MAX_PATH]; - TCHAR tszTimeStart[128]; - TCHAR tszTimeEnd[128]; - TCHAR tszMsgBuffer[10240]; - - memset(tszFileName, '\0', MAX_PATH); - memset(tszFileHash, '\0', MAX_PATH); - memset(tszTimeStart, '\0', sizeof(tszTimeStart)); - memset(tszTimeEnd, '\0', sizeof(tszTimeEnd)); - memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer)); - - int nListCount = 0; - XSTORAGECORE_DBFILE** ppSt_ListFile; - XStorageProtocol_Core_REQQueryFile(lpszMsgBuffer, tszTimeStart, tszTimeEnd, tszFileHash); - - if (0 == st_ServiceCfg.st_XSql.nSQLType) - { - st_HDRParam.bIsClose = TRUE; - st_HDRParam.nHttpCode = 406; - - RfcComponents_HttpServer_SendMsgEx(xhCenterHttp, tszSDBuffer, &nSDLen, &st_HDRParam); - XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_HTTPCENTER); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _T("业务客户端:%s,请求查询文件列表失败,服务器没有启用这个功能"), lpszClientAddr); - } - else - { - if (1 == st_ServiceCfg.st_XSql.nSQLType) - { - XStorageSQL_File_FileQuery(&ppSt_ListFile, &nListCount, tszTimeStart, tszTimeEnd, tszFileName, tszFileHash); - } - else - { - XStorage_SQLite_FileQuery(&ppSt_ListFile, &nListCount, tszTimeStart, tszTimeEnd, tszFileName, tszFileHash); - } - st_HDRParam.bIsClose = TRUE; - st_HDRParam.nHttpCode = 200; - - XStorageProtocol_Core_REPQueryFile(tszMsgBuffer, &nMsgLen, &ppSt_ListFile, nListCount, tszTimeStart, tszTimeEnd); - RfcComponents_HttpServer_SendMsgEx(xhCenterHttp, tszSDBuffer, &nSDLen, &st_HDRParam, tszMsgBuffer, nMsgLen); - XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_HTTPCENTER); - BaseLib_OperatorMemory_Free((XPPPMEM)&ppSt_ListFile, nListCount); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("业务客户端:%s,请求查询文件列表成功,列表个数:%d"), lpszClientAddr, nListCount); - } - } - return TRUE; -} \ No newline at end of file diff --git a/XEngine_Source/XEngine_StorageApp/Storage_APPTask/Storage_TaskQuery.h b/XEngine_Source/XEngine_StorageApp/Storage_APPTask/Storage_TaskQuery.h deleted file mode 100644 index a28740c..0000000 --- a/XEngine_Source/XEngine_StorageApp/Storage_APPTask/Storage_TaskQuery.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -//数据库操作 -BOOL XEngine_Task_Query(LPCTSTR lpszAPIName, LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int nMsgLen, RFCCOMPONENTS_HTTP_REQPARAM* pSt_HTTPParam, TCHAR** pptszListHdr, int nHdrCount); \ No newline at end of file diff --git a/XEngine_Source/XEngine_StorageApp/XEngine_StorageApp.cpp b/XEngine_Source/XEngine_StorageApp/XEngine_StorageApp.cpp index 02ff11b..729e1e0 100644 --- a/XEngine_Source/XEngine_StorageApp/XEngine_StorageApp.cpp +++ b/XEngine_Source/XEngine_StorageApp/XEngine_StorageApp.cpp @@ -105,6 +105,9 @@ static int ServiceApp_Deamon(int wait) int main(int argc, char** argv) { +#if (XENGINE_VERSION_KERNEL < 7) && (XENGINE_VERSION_MAIN < 19) + printf("XEngine版本过低,无法继续\n"); +#endif #ifdef _WINDOWS WSADATA st_WSAData; WSAStartup(MAKEWORD(2, 2), &st_WSAData); @@ -256,7 +259,7 @@ int main(int argc, char** argv) goto XENGINE_EXITAPP; } XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,启动用户管理服务成功")); - if (!Session_DLStroage_Init(st_ServiceCfg.st_XMax.nStorageDLThread)) + if (!Session_DLStroage_Init(st_ServiceCfg.st_XMax.nStorageDLThread, st_ServiceCfg.st_XLimit.nDLTry, st_ServiceCfg.st_XLimit.nDLError)) { XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("启动服务器中,启动下载会话服务失败,错误:%lX"), Session_GetLastError()); goto XENGINE_EXITAPP; @@ -271,7 +274,7 @@ int main(int argc, char** argv) if (!NetCore_TCPXCore_StartEx(&xhNetDownload, st_ServiceCfg.nStorageDLPort, st_ServiceCfg.st_XMax.nMaxClient, st_ServiceCfg.st_XMax.nIOThread)) { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("启动服务器中,启动下载存储网络服务失败,端口:%d,错误:%lX"), st_ServiceCfg.nStorageDLPort, NetCore_GetLastError()); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("启动服务器中,启动下载存储网络服务失败,端口:%d,错误:%lX,%d"), st_ServiceCfg.nStorageDLPort, NetCore_GetLastError(), errno); goto XENGINE_EXITAPP; } XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,启动下载存储网络服务成功,句柄:%llu,端口:%d,IO线程个数:%d"), xhNetDownload, st_ServiceCfg.nStorageDLPort, st_ServiceCfg.st_XMax.nIOThread); @@ -381,7 +384,7 @@ int main(int argc, char** argv) if (st_ServiceCfg.st_P2xp.nMode > 0) { - if (!NetCore_BroadCast_SendInit(&hBroadSocket, st_ServiceCfg.st_P2xp.nRVPort, st_ServiceCfg.tszIPAddr)) + if (!NetCore_BroadCast_RecvInit(&hBroadSocket, st_ServiceCfg.st_P2xp.nRVPort)) { XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("启动服务中,启动P2P存储广播服务失败,错误:%d"), errno); goto XENGINE_EXITAPP; diff --git a/XEngine_Source/XEngine_StorageApp/XEngine_StorageApp.vcxproj b/XEngine_Source/XEngine_StorageApp/XEngine_StorageApp.vcxproj index 3792b02..8b7c383 100644 --- a/XEngine_Source/XEngine_StorageApp/XEngine_StorageApp.vcxproj +++ b/XEngine_Source/XEngine_StorageApp/XEngine_StorageApp.vcxproj @@ -160,7 +160,6 @@ - @@ -177,7 +176,6 @@ - diff --git a/XEngine_Source/XEngine_StorageApp/XEngine_StorageApp.vcxproj.filters b/XEngine_Source/XEngine_StorageApp/XEngine_StorageApp.vcxproj.filters index a367700..95580f2 100644 --- a/XEngine_Source/XEngine_StorageApp/XEngine_StorageApp.vcxproj.filters +++ b/XEngine_Source/XEngine_StorageApp/XEngine_StorageApp.vcxproj.filters @@ -51,9 +51,6 @@ 源文件\Storage_APPTask - - 源文件\Storage_APPTask - 源文件\Storage_APPHelp @@ -92,9 +89,6 @@ 头文件\Storage_APPTask - - 头文件\Storage_APPTask - 头文件\Storage_APPHelp diff --git a/XEngine_Source/XEngine_StorageComponents/XStorage_Protocol/XStorageProtocol_Core/XStorageProtocol_Core.cpp b/XEngine_Source/XEngine_StorageComponents/XStorage_Protocol/XStorageProtocol_Core/XStorageProtocol_Core.cpp index a54669d..b076d6f 100644 --- a/XEngine_Source/XEngine_StorageComponents/XStorage_Protocol/XStorageProtocol_Core/XStorageProtocol_Core.cpp +++ b/XEngine_Source/XEngine_StorageComponents/XStorage_Protocol/XStorageProtocol_Core/XStorageProtocol_Core.cpp @@ -133,12 +133,17 @@ BOOL CXStorageProtocol_Core::XStorageProtocol_Core_REQQueryFile(LPCTSTR lpszMsgB 类型:整数型 可空:N 意思:输入文件列表个数 - 参数.五:lpszTimeStart + 参数.五:lpszRootDir + In/Out:In + 类型:常量字符指针 + 可空:Y + 意思:某些时候可能需要跳过字符串 + 参数.六:lpszTimeStart In/Out:In 类型:常量字符指针 可空:Y 意思:输入查询请求的开始时间 - 参数.六:lpszTimeEnd + 参数.七:lpszTimeEnd In/Out:In 类型:常量字符指针 可空:Y @@ -148,7 +153,7 @@ BOOL CXStorageProtocol_Core::XStorageProtocol_Core_REQQueryFile(LPCTSTR lpszMsgB 意思:是否成功 备注: *********************************************************************/ -BOOL CXStorageProtocol_Core::XStorageProtocol_Core_REPQueryFile(TCHAR* ptszMsgBuffer, int* pInt_MsgLen, XSTORAGECORE_DBFILE*** pppSt_DBFile, int nListCount, LPCTSTR lpszTimeStart, LPCTSTR lpszTimeEnd) +BOOL CXStorageProtocol_Core::XStorageProtocol_Core_REPQueryFile(TCHAR* ptszMsgBuffer, int* pInt_MsgLen, XSTORAGECORE_DBFILE*** pppSt_DBFile, int nListCount, LPCTSTR lpszRootDir, LPCTSTR lpszTimeStart, LPCTSTR lpszTimeEnd) { XStorage_IsErrorOccur = FALSE; @@ -164,7 +169,22 @@ BOOL CXStorageProtocol_Core::XStorageProtocol_Core_REPQueryFile(TCHAR* ptszMsgBu for (int i = 0; i < nListCount; i++) { Json::Value st_JsonObject; - st_JsonObject["tszFilePath"] = (*pppSt_DBFile)[i]->st_ProtocolFile.tszFilePath; + + if (NULL == lpszRootDir) + { + st_JsonObject["tszFilePath"] = (*pppSt_DBFile)[i]->st_ProtocolFile.tszFilePath; + } + else + { + if (NULL == _tcsstr((*pppSt_DBFile)[i]->st_ProtocolFile.tszFilePath, lpszRootDir)) + { + st_JsonObject["tszFilePath"] = (*pppSt_DBFile)[i]->st_ProtocolFile.tszFilePath; + } + else + { + st_JsonObject["tszFilePath"] = (*pppSt_DBFile)[i]->st_ProtocolFile.tszFilePath + _tcslen(lpszRootDir); + } + } st_JsonObject["tszFileName"] = (*pppSt_DBFile)[i]->st_ProtocolFile.tszFileName; st_JsonObject["tszFileUser"] = (*pppSt_DBFile)[i]->st_ProtocolFile.tszFileUser; st_JsonObject["tszFileHash"] = (*pppSt_DBFile)[i]->st_ProtocolFile.tszFileHash; @@ -328,7 +348,7 @@ BOOL CXStorageProtocol_Core::XStorageProtocol_Core_REQDirOperator(LPCTSTR lpszMs delete pSt_JsonReader; pSt_JsonReader = NULL; - *pInt_Operator = st_JsonRoot["lpszUserDir"].asInt(); + *pInt_Operator = st_JsonRoot["nOPerator"].asInt(); _tcscpy(ptszUserDir, st_JsonRoot["lpszUserDir"].asCString()); return TRUE; } @@ -382,7 +402,7 @@ BOOL CXStorageProtocol_Core::XStorageProtocol_Core_REPDirOperator(TCHAR* ptszMsg st_JsonRoot["Count"] = st_JsonArray.size(); st_JsonRoot["List"] = st_JsonArray; st_JsonRoot["Code"] = 0; - st_JsonRoot["Msg"] = _T("查询用户目录成功"); + st_JsonRoot["Msg"] = _T("ok"); //打包输出信息 *pInt_MsgLen = st_JsonRoot.toStyledString().length(); memcpy(ptszMsgBuffer, st_JsonRoot.toStyledString().c_str(), *pInt_MsgLen); diff --git a/XEngine_Source/XEngine_StorageComponents/XStorage_Protocol/XStorageProtocol_Core/XStorageProtocol_Core.h b/XEngine_Source/XEngine_StorageComponents/XStorage_Protocol/XStorageProtocol_Core/XStorageProtocol_Core.h index 3cee3aa..27c7ce8 100644 --- a/XEngine_Source/XEngine_StorageComponents/XStorage_Protocol/XStorageProtocol_Core/XStorageProtocol_Core.h +++ b/XEngine_Source/XEngine_StorageComponents/XStorage_Protocol/XStorageProtocol_Core/XStorageProtocol_Core.h @@ -18,7 +18,7 @@ class CXStorageProtocol_Core ~CXStorageProtocol_Core(); public: BOOL XStorageProtocol_Core_REQQueryFile(LPCTSTR lpszMsgBuffer, TCHAR *ptszTimeStart, TCHAR *ptszTimeEnd, TCHAR *ptszFileName = NULL, TCHAR * ptszFileHash = NULL); - BOOL XStorageProtocol_Core_REPQueryFile(TCHAR *ptszMsgBuffer, int *pInt_MsgLen, XSTORAGECORE_DBFILE*** pppSt_DBFile, int nListCount, LPCTSTR lpszTimeStart = NULL, LPCTSTR lpszTimeEnd = NULL); + BOOL XStorageProtocol_Core_REPQueryFile(TCHAR *ptszMsgBuffer, int *pInt_MsgLen, XSTORAGECORE_DBFILE*** pppSt_DBFile, int nListCount, LPCTSTR lpszRootDir, LPCTSTR lpszTimeStart = NULL, LPCTSTR lpszTimeEnd = NULL); BOOL XStorageProtocol_Core_ReportFileParse(LPCTSTR lpszMsgBuffer, int nMsgLen, XSTORAGECORE_DBFILE*** pppSt_DBFile, int* pInt_ListCount); public: BOOL XStorageProtocol_Core_REQDirOperator(LPCTSTR lpszMsgBuffer, TCHAR* ptszUserDir, int* pInt_Operator); diff --git a/XEngine_Source/XEngine_StorageComponents/XStorage_Protocol/XStorageProtocol_Define.h b/XEngine_Source/XEngine_StorageComponents/XStorage_Protocol/XStorageProtocol_Define.h index 47ece9c..1c84125 100644 --- a/XEngine_Source/XEngine_StorageComponents/XStorage_Protocol/XStorageProtocol_Define.h +++ b/XEngine_Source/XEngine_StorageComponents/XStorage_Protocol/XStorageProtocol_Define.h @@ -289,12 +289,17 @@ extern "C" BOOL XStorageProtocol_Core_REQQueryFile(LPCSTR lpszMsgBuffer, CHAR *p 类型:整数型 可空:N 意思:输入文件列表个数 - 参数.五:lpszTimeStart + 参数.五:lpszRootDir + In/Out:In + 类型:常量字符指针 + 可空:Y + 意思:某些时候可能需要跳过字符串 + 参数.六:lpszTimeStart In/Out:In 类型:常量字符指针 可空:Y 意思:输入查询请求的开始时间 - 参数.六:lpszTimeEnd + 参数.七:lpszTimeEnd In/Out:In 类型:常量字符指针 可空:Y @@ -304,7 +309,7 @@ extern "C" BOOL XStorageProtocol_Core_REQQueryFile(LPCSTR lpszMsgBuffer, CHAR *p 意思:是否成功 备注: *********************************************************************/ -extern "C" BOOL XStorageProtocol_Core_REPQueryFile(CHAR *ptszMsgBuffer, int *pInt_MsgLen, XSTORAGECORE_DBFILE * **pppSt_DBFile, int nListCount, LPCSTR lpszTimeStart = NULL, LPCSTR lpszTimeEnd = NULL); +extern "C" BOOL XStorageProtocol_Core_REPQueryFile(CHAR * ptszMsgBuffer, int* pInt_MsgLen, XSTORAGECORE_DBFILE * **pppSt_DBFile, int nListCount, LPCTSTR lpszRootDir, LPCSTR lpszTimeStart = NULL, LPCSTR lpszTimeEnd = NULL); /******************************************************************** 函数名称:XStorageProtocol_Core_ReportFileParse 函数功能:解析文件报告协议 diff --git a/XEngine_Source/XEngine_StorageComponents/XStorage_Protocol/pch.cpp b/XEngine_Source/XEngine_StorageComponents/XStorage_Protocol/pch.cpp index 66b25ea..48e769b 100644 --- a/XEngine_Source/XEngine_StorageComponents/XStorage_Protocol/pch.cpp +++ b/XEngine_Source/XEngine_StorageComponents/XStorage_Protocol/pch.cpp @@ -67,9 +67,9 @@ extern "C" BOOL XStorageProtocol_Core_REQQueryFile(LPCTSTR lpszMsgBuffer, TCHAR { return m_ProtocolCore.XStorageProtocol_Core_REQQueryFile(lpszMsgBuffer, ptszTimeStart, ptszTimeEnd, ptszFileName, ptszFileHash); } -extern "C" BOOL XStorageProtocol_Core_REPQueryFile(TCHAR * ptszMsgBuffer, int* pInt_MsgLen, XSTORAGECORE_DBFILE * **pppSt_DBFile, int nListCount, LPCTSTR lpszTimeStart, LPCTSTR lpszTimeEnd) +extern "C" BOOL XStorageProtocol_Core_REPQueryFile(TCHAR * ptszMsgBuffer, int* pInt_MsgLen, XSTORAGECORE_DBFILE * **pppSt_DBFile, int nListCount, LPCTSTR lpszRootDir, LPCTSTR lpszTimeStart, LPCTSTR lpszTimeEnd) { - return m_ProtocolCore.XStorageProtocol_Core_REPQueryFile(ptszMsgBuffer, pInt_MsgLen, pppSt_DBFile, nListCount, lpszTimeStart, lpszTimeEnd); + return m_ProtocolCore.XStorageProtocol_Core_REPQueryFile(ptszMsgBuffer, pInt_MsgLen, pppSt_DBFile, nListCount, lpszRootDir, lpszTimeStart, lpszTimeEnd); } extern "C" BOOL XStorageProtocol_Core_ReportFileParse(LPCTSTR lpszMsgBuffer, int nMsgLen, XSTORAGECORE_DBFILE * **pppSt_DBFile, int* pInt_ListCount) {