HRESULT CDIL_CAN_STUB::CAN_PerformClosureOperations(void) { //First remove all the client for (UINT nCount = 0; nCount < sg_unClientCnt; nCount++) { CAN_RegisterClient(FALSE, sg_asClientToBufMap[nCount].dwClientID, _T("")); } // First disconnect from the simulation engine CAN_DeselectHwInterface(); // Then terminate the broker thread sg_sBrokerObjBusEmulation.bTerminateThread(); // Close the notification event if (NULL != sg_hNotifyFinish) { CloseHandle(sg_hNotifyFinish); sg_hNotifyFinish = NULL; } // Delete the critical section DeleteCriticalSection(&sg_CSBroker); sg_pIlog = NULL; // Log interface pointer SetCurrState(STATE_PRIMORDIAL); return S_OK; }
/** * Close doen the iView interface driver. * Remove all the clients and buffers. * Stop the mDNS browser deselect the interfaces and * delete all the registered VCIs. */ HRESULT CDIL_CAN_i_VIEW::CAN_PerformClosureOperations(void) { VALIDATE_VALUE_RETURN_VAL(m_CurrState, STATE_DRIVER_SELECTED, ERR_IMPROPER_STATE); pClientMap_t Clients = m_Clients; pClientMap_t::iterator CItr = Clients.begin(); for (; CItr != Clients.end(); CItr++ ) { DWORD Id = CItr->first; CAN_RegisterClient(FALSE, Id, nullptr); } if (m_iViewBrowser) { m_iViewBrowser->Stop(); delete m_iViewBrowser; } if( m_CurrState == STATE_CONNECTED ) { CAN_StopHardware(); } CAN_DeselectHwInterface(); EnterCriticalSection(&m_Mutex); pVCIMap_t::iterator VItr = m_VCI.begin(); for (; VItr != m_VCI.end(); VItr++ ) { delete VItr->second->VCiIF(); delete VItr->second; } LeaveCriticalSection(&m_Mutex); DeleteCriticalSection(&m_Mutex); m_CurrState = STATE_DRIVER_LOADED; return S_OK; }