下面的switch +case 和 线程同步用的有神马问题吗?我的主管加主管的主管都不会
UINT32 ulMsgId=OMT_NTOHL(pOMTMsg->ulMsgId);
switch(ulMsgId)
{
case APP_OM_SHAKEHAND_CNF_MSG_ID:
{
ProcessResponseMsgs(pOMTMsg);
break;
}
case ID_APP_MM_INQ_IMSI_CNF_V2:
{
ProcessResponseMsgs(pOMTMsg);
SetEvent(g_hEventimsi);
//break;
}
case ID_APP_MM_INQ_MM_INFO_CNF_V2:
{
ProcessResponseMsgs(pOMTMsg);
SetEvent(g_hEventtmsi);
//break;
}
case ID_PHY_DT_DL_SINR_IND:
{
ProcessResponseMsgs(pOMTMsg);
SetEvent(g_hEventsin);
//break;
}
case ID_RRC_APP_INQUIRE_CAMP_CELL_INFO_IND:
{
ProcessResponseMsgs(pOMTMsg);
SetEvent(g_hEventcell);
//break;
}
}
打印日志:值得一提的是 同一话 打印了3遍,我想问问 是不是和我上面的//break 注释掉 有关系
代码在下面
[05-05 15:57:39.331][CRespMsgInfo][SetRspMsgInfo]rev unexpected msg 0x31c01203
[05-05 15:57:39.331][CRespMsgInfo][SetRspMsgInfo]rev unexpected msg 0x31c01203
[05-05 15:57:39.331][CRespMsgInfo][SetRspMsgInfo]rev unexpected msg 0x31c01203
[05-05 15:57:39.331][CUECtrlV20][SearchTMSI]SearchTmsiStatus: command success
另外 ,最后一句 竟然没有报失败:command success
值得一提的是,我在主线程里做了线程同步的,主线程代码在最后面,我要问的是怎么没超时啊!?
下面是接收和处理消息的线程
BOOL CUECtrlV20::ProcessResponseMsgs(OM_MSG_STRU_V2* pOmMsg)
{
//here not need big to little,it has been done
if(APP_OM_SHAKEHAND_CNF_MSG_ID == OMT_HTONL(pOmMsg->ulMsgId))
{
m_usOriginalId = (pOmMsg->usOriginalId);
//SetEvent(g_hEvent);
SetEvent(m_Event);//
Sleep(100);
return TRUE;//
}
else
{
// if(ID_APP_MM_INQ_IMSI_CNF_V2 == OMT_HTONL(pOmMsg->ulMsgId)||ID_APP_MM_INQ_MM_INFO_CNF_V2 == OMT_HTONL(pOmMsg->ulMsgId)||ID_PHY_DT_DL_SINR_IND == OMT_HTONL(pOmMsg->ulMsgId))
//{
m_respMsgInfo.SetRspMsgInfo(pOmMsg);
//}
}
return TRUE;
}
VOID CRespMsgInfo::SetRspMsgInfo(OM_MSG_STRU_V2* pucInfo )
{
if(0 == pucInfo)
{
PRINT_LOG("CRespMsgInfo","SetRspMsgInfo","%s","input null ptr!");
return;
}
CMYCriticalSection lock(&m_csLock, TRUE);
if(OMT_HTONL(pucInfo->ulMsgId) == m_ulResponseMsgId)
{
PRINT_LOG("CRespMsgInfo","SetRspMsgInfo","rev right msg 0x%x",m_ulResponseMsgId);// //m_ulIsUpdated = TRUE;
//ResetEvent(g_hEvent);
m_ulInfoLen = OMT_HTONL(pucInfo->ulLength) - 20;
memcpy(m_aucInfo,pucInfo->aucPara,m_ulInfoLen);
}
else
{
PRINT_LOG("CRespMsgInfo","SetRspMsgInfo","rev unexpected msg 0x%x",pucInfo->ulMsgId);
}
return;
}
------解决方案--------------------------------------------------------
------解决方案--------------------------------------------------------
不要动不动就贴代码,说思路
------解决方案--------------------------------------------------------
你这一大坨代码 很难让人理解啊
------解决方案--------------------------------------------------------
为啥注释掉break?
switch分支不加break,满足一个分支条件后,后面所有分支的代码都会执行
------解决方案--------------------------------------------------------
唔。废话,break注释掉,在case ID_APP_MM_INQ_IMSI_CNF_V2的时候,不就执行的是:
ProcessResponseMsgs(pOMTMsg);
SetEvent(g_hEventimsi);
ProcessResponseMsgs(pOMTMsg);
SetEvent(g_hEventtmsi);
ProcessResponseMsgs(pOMTMsg);
SetEvent(g_hEventsin);
ProcessResponseMsgs(pOMTMsg);
SetEvent(g_hEventcell);
但是在SetRspMsgInfo里,前三次在执行到
if(OMT_HTONL(pucInfo->ulMsgId) == m_ulResponseMsgId)