int CMain::SessionTimeOutHandler() { int nRet = 0; time_t curTm = 0; CSession *cSession = NULL; curTm = time(NULL); while(m_lstSession.size()){ cSession = m_lstSession.front(); if((curTm - cSession->GetSendTime()) <= m_nTimeOut){ return CLA_OK; } CLA_LOG(CLA_ERR,false,"Session timeout(curTm=%lu, sendTime=%lu, diff=%lu sessionId=%d, timeOut=%d)\n", curTm, cSession->GetSendTime(), (curTm - cSession->GetSendTime()), cSession->GetSessionId(), m_nTimeOut); nRet = UpdateHistErr(cSession, CLA_RSLT_CODE_TIME_OUT); if(nRet != CLA_OK){ CLA_LOG(CLA_ERR,false,"Command history update failed(nRet=%d)\n",nRet); } delete cSession; m_lstSession.pop_front(); } return CLA_OK; }
CSession* CMain::FindSession(unsigned int a_nSessionId) { CSession *cSession = NULL; list<CSession*>::iterator iter; for(iter = m_lstSession.begin();iter != m_lstSession.end(); iter++){ cSession = *iter; if(cSession->GetSessionId() == a_nSessionId){ m_lstSession.erase(iter); return cSession; } } return NULL; }