|
@@ -251,6 +251,17 @@ DWORD WINAPI _parse_package_data(LPVOID lparam)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+DWORD WINAPI _parse_data_server(LPVOID lparam)
|
|
|
+{
|
|
|
+ ParseData* data = (ParseData*)lparam;
|
|
|
+ CYAServerDlg* dlg = reinterpret_cast<CYAServerDlg*>(data->handle);
|
|
|
+ //dlg->parse_package_data(data->buf, data->len, data->dwConnID);
|
|
|
+ dlg->parse_data_server(data->buf, data->len, data->dwConnID);
|
|
|
+
|
|
|
+ free(data);
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
UINT _thread_timer(LPVOID lparam)
|
|
|
{
|
|
|
CYAServerDlg* dlg = reinterpret_cast<CYAServerDlg*>(lparam);
|
|
@@ -563,8 +574,7 @@ void CYAServerDlg::init_param()
|
|
|
InitializeCriticalSection(&m_csWriteLog);
|
|
|
InitializeCriticalSection(&m_csRefreshList);
|
|
|
InitializeCriticalSection(&m_csRemoveSocket);
|
|
|
- InitializeCriticalSection(&m_csSyncTime);
|
|
|
- //InitializeCriticalSection(&m_csAddDist);
|
|
|
+ InitializeCriticalSection(&m_csParseDataServer);
|
|
|
|
|
|
//down_mine_count.count_vehicle = 0;
|
|
|
//down_mine_count.count_person = 0;
|
|
@@ -639,9 +649,8 @@ void CYAServerDlg::stop_and_exit()
|
|
|
WaitForSingleObject(m_thread_timer->m_hThread, INFINITE);
|
|
|
}
|
|
|
m_thread_timer = NULL;
|
|
|
- //DeleteCriticalSection(&m_csAddDist);
|
|
|
- DeleteCriticalSection(&m_csSyncTime);
|
|
|
DeleteCriticalSection(&m_csWriteLog);
|
|
|
+ DeleteCriticalSection(&m_csParseDataServer);
|
|
|
DeleteCriticalSection(&m_csRemoveSocket);
|
|
|
DeleteCriticalSection(&m_csRefreshList);
|
|
|
}
|
|
@@ -3032,11 +3041,8 @@ void CYAServerDlg::card_leave_area( Card* card, Area* area)
|
|
|
store_data_card(card, ALARM_CARD_AREA_FORBIDDEN_END);
|
|
|
deal_alarm_card(card, alarm_forbidden_map, false, AF_CARD_AREA_FORBIDDEN);
|
|
|
// 先处理,后删除
|
|
|
-<<<<<<< HEAD
|
|
|
|
|
|
//card_map->erase(it_card);
|
|
|
-=======
|
|
|
->>>>>>> 0ddd3a57289869c1f9228aef8255d1da501b50c5
|
|
|
if(it_card != card_map->end()){
|
|
|
card_map->erase(it_card);
|
|
|
}
|
|
@@ -5487,7 +5493,16 @@ EnHandleResult CYAServerDlg::OnSend( ITcpServer* pSender, CONNID dwConnID, const
|
|
|
EnHandleResult CYAServerDlg::OnReceive( ITcpServer* pSender, CONNID dwConnID, const BYTE* pData, int iLength )
|
|
|
{
|
|
|
DWORD dw = ::GetTickCount();
|
|
|
- parse_data_server(pData, iLength, dwConnID);
|
|
|
+
|
|
|
+ ParseData *data = (ParseData*)malloc(sizeof(ParseData));
|
|
|
+ data->handle = this;
|
|
|
+ data->dwConnID = dwConnID;
|
|
|
+ data->len = iLength;
|
|
|
+ memset(data->buf, 0, LENGTH_MSG_4K);
|
|
|
+ memcpy(data->buf, pData, iLength);
|
|
|
+
|
|
|
+ QueueUserWorkItem(_parse_data_server, (LPVOID)data, WT_EXECUTEDEFAULT);
|
|
|
+ //parse_data_server(pData, iLength, dwConnID);
|
|
|
TRACE(_T("parse_data_server: %d, %d, %d\r\n"), ::GetTickCount() - dw, dwConnID, iLength);
|
|
|
return HR_OK;
|
|
|
}
|
|
@@ -5886,11 +5901,12 @@ afx_msg LRESULT CYAServerDlg::OnWriteErrorLog(WPARAM wParam, LPARAM lParam)
|
|
|
|
|
|
void CYAServerDlg::parse_data_server( const BYTE * pData, int nLen, DWORD dwConnId )
|
|
|
{
|
|
|
- if(m_log_raw_data){
|
|
|
- //CString strBuf;
|
|
|
- //formatByteArray(strBuf, (BYTE*)pData, nLen);
|
|
|
- //writeErrorLog(_T("RAW_SSSS"), strBuf, false);
|
|
|
- }
|
|
|
+ EnterCriticalSection(&m_csParseDataServer);
|
|
|
+ //if(m_log_raw_data){
|
|
|
+ // //CString strBuf;
|
|
|
+ // //formatByteArray(strBuf, (BYTE*)pData, nLen);
|
|
|
+ // //writeErrorLog(_T("RAW_SSSS"), strBuf, false);
|
|
|
+ //}
|
|
|
|
|
|
int read_length = 0;
|
|
|
int pkg_len = 0;
|
|
@@ -5904,8 +5920,9 @@ void CYAServerDlg::parse_data_server( const BYTE * pData, int nLen, DWORD dwConn
|
|
|
//ASSERT(0);
|
|
|
return ;
|
|
|
}
|
|
|
-
|
|
|
- memcpy(Buf, it->second->pData, it->second->wReadLen);
|
|
|
+ if(it->second->wReadLen > 0){
|
|
|
+ memcpy(Buf, it->second->pData, it->second->wReadLen);
|
|
|
+ }
|
|
|
memcpy(&Buf[it->second->wReadLen], pData, nLen);
|
|
|
nLen += it->second->wReadLen;
|
|
|
// read_length = it->second->wReadLen + nLen;
|
|
@@ -5913,14 +5930,16 @@ void CYAServerDlg::parse_data_server( const BYTE * pData, int nLen, DWORD dwConn
|
|
|
memcpy(Buf, pData, nLen);
|
|
|
}
|
|
|
|
|
|
- while (read_length < nLen){
|
|
|
+ while (read_length < nLen && read_length < LENGTH_MSG_4K){
|
|
|
pkg_len = MAKEWORD(Buf[read_length + 1], Buf[read_length]);
|
|
|
pkg_len += sizeof(WORD); // 长度
|
|
|
|
|
|
if(read_length + pkg_len > nLen){
|
|
|
break; // 有半个包,溢出,保留与下个包合并
|
|
|
}
|
|
|
- read_length += pkg_len ;
|
|
|
+ read_length += pkg_len ;
|
|
|
+
|
|
|
+ TRACE(_T("read_length: %d, nLen: %d \n"),read_length, nLen);
|
|
|
}
|
|
|
|
|
|
if(read_length > 0){
|
|
@@ -5931,14 +5950,23 @@ void CYAServerDlg::parse_data_server( const BYTE * pData, int nLen, DWORD dwConn
|
|
|
memset(data->buf, 0, LENGTH_MSG_4K);
|
|
|
memcpy(data->buf, Buf, read_length);
|
|
|
|
|
|
+<<<<<<< HEAD
|
|
|
QueueUserWorkItem(_parse_package_data, (LPVOID)data, WT_EXECUTEDEFAULT);
|
|
|
- // parse_data_receive_package(Buf, read_length, dwConnId);
|
|
|
+ //parse_data_receive_package(Buf, read_length, dwConnId);
|
|
|
+=======
|
|
|
+ //QueueUserWorkItem(_parse_package_data, (LPVOID)data, WT_EXECUTEDEFAULT);
|
|
|
+ parse_data_receive_package(Buf, read_length, dwConnId);
|
|
|
+>>>>>>> 5370472cf28a099ed7170d49ef758239f41652b6
|
|
|
}
|
|
|
|
|
|
if(read_length >= nLen){ //没剩下数据, 直接解析
|
|
|
if(it != mp_socket_buffer_list.end()){
|
|
|
+ it->second->wLen = 0;
|
|
|
+ it->second->wReadLen = 0;
|
|
|
+ it->second->dwConnID = dwConnId;
|
|
|
+ memset(it->second->pData, 0, LENGTH_MSG_1M);
|
|
|
//_SOCKET_BUFFER* pp = it->second;
|
|
|
- mp_socket_buffer_list.erase(it);
|
|
|
+ //mp_socket_buffer_list.erase(it);
|
|
|
//free(pp);
|
|
|
//bt = NULL;
|
|
|
}
|
|
@@ -5946,7 +5974,9 @@ void CYAServerDlg::parse_data_server( const BYTE * pData, int nLen, DWORD dwConn
|
|
|
if(it != mp_socket_buffer_list.end()){
|
|
|
//it->second->wLen = pkg_len - sizeof(WORD);
|
|
|
try{
|
|
|
- memset(&it->second->pData[it->second->wReadLen], 0, LENGTH_MSG_1M);
|
|
|
+ if(it->second->wReadLen > 0){
|
|
|
+ memset(&it->second->pData[it->second->wReadLen], 0, LENGTH_MSG_1M);
|
|
|
+ }
|
|
|
}catch(...){
|
|
|
int tt = it->second->wReadLen;
|
|
|
}
|
|
@@ -5968,9 +5998,10 @@ void CYAServerDlg::parse_data_server( const BYTE * pData, int nLen, DWORD dwConn
|
|
|
mp_socket_buffer_list.insert(make_pair(dwConnId, _sockbuf));
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
delete Buf;
|
|
|
Buf = NULL;
|
|
|
+ //delete pData;
|
|
|
+ LeaveCriticalSection(&m_csParseDataServer);
|
|
|
}
|
|
|
|
|
|
void CYAServerDlg::parse_data_receive_package(BYTE *pData, int nLen, DWORD dwConnID )
|
|
@@ -5990,6 +6021,8 @@ void CYAServerDlg::parse_data_receive_package(BYTE *pData, int nLen, DWORD dwCon
|
|
|
/*parse_data_receive(Buf, pkg_len, dwConnID);*/
|
|
|
|
|
|
read_length += pkg_len + sizeof(WORD);
|
|
|
+
|
|
|
+ TRACE(_T("parse_data_receive_package : read_length: %d, nLen: %d \n"),read_length, nLen);
|
|
|
}
|
|
|
delete Buf;
|
|
|
Buf = NULL;
|