Skip to content

Commit 7435df2

Browse files
committed
Fixed: Can not receive broadcast messages on other machines
1 parent c682403 commit 7435df2

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

XEngine_Source/XEngine_StorageApp/StorageApp_UPLoader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ BOOL XEngine_Task_HttpUPLoader(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, in
192192
else
193193
{
194194
_stprintf(tszFileDir, _T("%s%s"), st_ServiceCfg.st_XStorage.tszFileDir, pSt_HTTPParam->tszHttpUri);
195-
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("上传客户端:%s,请求上传文件中,文件名:%s,大小:%d"), lpszClientAddr, tszFileDir, nMsgLen);
195+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_DEBUG, _T("上传客户端:%s,请求上传文件中,文件名:%s,大小:%d"), lpszClientAddr, tszFileDir, nMsgLen);
196196
}
197197

198198
return TRUE;

XEngine_Source/XEngine_StorageApp/Storage_APPTask/Storage_TaskManage.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,10 @@ BOOL XEngine_Task_Manage(LPCTSTR lpszAPIName, LPCTSTR lpszClientAddr, LPCTSTR lp
221221
int nListCount = 0;
222222
CHAR** ppszListDir = NULL;
223223
TCHAR tszUserDir[MAX_PATH];
224-
TCHAR tszRealDir[MAX_PATH];
224+
TCHAR tszRealDir[1024];
225225

226226
memset(tszUserDir, '\0', MAX_PATH);
227-
memset(tszRealDir, '\0', MAX_PATH);
227+
memset(tszRealDir, '\0', sizeof(tszRealDir));
228228

229229
st_HDRParam.bIsClose = TRUE;
230230
st_HDRParam.nHttpCode = 200;

XEngine_Source/XEngine_StorageApp/Storage_APPTask/Storage_TaskP2p.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ BOOL XEngine_Task_P2PGet(LPCTSTR lpszFileHash, LPCTSTR lpszClientAddr, RFCCOMPON
8787
st_HDRParam.bIsClose = TRUE;
8888
st_HDRParam.nHttpCode = 200;
8989

90-
_stprintf(pppSt_ListFile[0]->tszTableName, _T("127.0.0.1"));
90+
_stprintf(pppSt_ListFile[0]->tszTableName, _T("127.0.0.1:%d"), st_ServiceCfg.nStorageDLPort);
9191
XStorageProtocol_Core_REPQueryFile(tszRVBuffer, &nRVLen, &pppSt_ListFile, nListCount);
9292
BaseLib_OperatorMemory_Free((XPPPMEM)&pppSt_ListFile, nListCount);
9393

@@ -121,8 +121,15 @@ BOOL XEngine_Task_P2PGet(LPCTSTR lpszFileHash, LPCTSTR lpszClientAddr, RFCCOMPON
121121
else
122122
{
123123
//开始广播请求文件
124+
SOCKET hSDSocket;
125+
SOCKET hRVSocket;
126+
list<APIHELP_LBFILEINFO> stl_ListFile;
127+
124128
XStorageProtocol_Client_REQQueryFile(tszSDBuffer, &nSDLen, NULL, lpszFileHash);
125-
if (!NetCore_BroadCast_Send(hBroadSocket, tszSDBuffer, nSDLen))
129+
NetCore_BroadCast_SendInit(&hSDSocket, st_ServiceCfg.st_P2xp.nRVPort, st_ServiceCfg.tszIPAddr);
130+
NetCore_BroadCast_RecvInit(&hRVSocket, st_ServiceCfg.st_P2xp.nSDPort);
131+
132+
if (!NetCore_BroadCast_Send(hSDSocket, tszSDBuffer, nSDLen))
126133
{
127134
st_HDRParam.bIsClose = TRUE;
128135
st_HDRParam.nHttpCode = 500;
@@ -132,10 +139,8 @@ BOOL XEngine_Task_P2PGet(LPCTSTR lpszFileHash, LPCTSTR lpszClientAddr, RFCCOMPON
132139
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("广播端:%s,发送广播请求失败,错误:%lX"), lpszClientAddr, NetCore_GetLastError());
133140
return FALSE;
134141
}
135-
136-
SOCKET hRVSocket;
137-
list<APIHELP_LBFILEINFO> stl_ListFile;
138-
NetCore_BroadCast_RecvInit(&hRVSocket, st_ServiceCfg.st_P2xp.nSDPort);
142+
NetCore_BroadCast_Close(hSDSocket);
143+
139144
time_t nTimeStart = time(NULL);
140145
while (1)
141146
{

XEngine_Source/XEngine_StorageApp/XEngine_StorageApp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ int main(int argc, char** argv)
381381

382382
if (st_ServiceCfg.st_P2xp.nMode > 0)
383383
{
384-
if (!NetCore_BroadCast_SendInit(&hBroadSocket, st_ServiceCfg.st_P2xp.nRVPort, st_ServiceCfg.tszIPAddr))
384+
if (!NetCore_BroadCast_RecvInit(&hBroadSocket, st_ServiceCfg.st_P2xp.nRVPort))
385385
{
386386
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("启动服务中,启动P2P存储广播服务失败,错误:%d"), errno);
387387
goto XENGINE_EXITAPP;

0 commit comments

Comments
 (0)