发现2个BUG,各位达人帮忙看看是不是:
bool CClientReConnectManager::SetHandler(int nServerID, CConnectClient* pConnectClient)
{
if(NULL == pConnectClient)
{
OUR_DEBUG((LM_ERROR, "[CProConnectManager::SetHandler]pProConnectClient is NULL.\n"));
return false;
}
ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_ThreadWritrLock);
mapReactorConnectInfo::iterator f = m_mapConnectInfo.find(nServerID);
if(f == m_mapConnectInfo.end())
{
//如果这个链接已经存在,则不再添加到已经存在的客户端map管理中
OUR_DEBUG((LM_ERROR, "[CProConnectManager::SetHandler]nServerID =(%d) is exist.\n", nServerID));
return false;
}
return true;
}
1、红色应该改为:if(f != m_mapConnectInfo.end())
2、在“return true”上一行添加:
pConnectClient->SetServerID(m_nServerID);
pConnectClient->reactor(m_pReactor);
if(m_pReactorConnect->connect(pConnectClient, m_AddrServer) == -1)
{
OUR_DEBUG((LM_ERROR, "[CReactorClientInfo::Run]m_pAsynchConnect open error(%d).\n", ACE_OS::last_error()));
//这里设置为True,为了让自动重试起作用
return true;
} |