BOOL CNdasUnitDiskDevice::HasSameDIBInfo() { CNdasUnitDeviceCreator udCreator(*GetParentDevice(), GetUnitNo()); CNdasUnitDevice* pUnitDeviceNow = udCreator.CreateUnitDevice(); if(NULL == pUnitDeviceNow) { return FALSE; } if (GetType() != pUnitDeviceNow->GetType()) { delete pUnitDeviceNow; return FALSE; } CNdasUnitDiskDevice* pUnitDiskDeviceNow = reinterpret_cast<CNdasUnitDiskDevice*>(pUnitDeviceNow); if(!HasSameDIBInfo(*pUnitDiskDeviceNow)) { delete pUnitDeviceNow; return FALSE; } delete pUnitDeviceNow; return TRUE; }
BOOL CNdasUnitDiskDevice::HasSameDIBInfo() { CNdasUnitDeviceCreator udCreator(GetParentDevice(), GetUnitNo()); CNdasUnitDevicePtr pUnitDeviceNow( udCreator.CreateUnitDevice() ); if (CNdasUnitDeviceNullPtr== pUnitDeviceNow) { return FALSE; } if (GetType() != pUnitDeviceNow->GetType()) { return FALSE; } CNdasUnitDiskDevice* pUnitDiskDeviceNow = reinterpret_cast<CNdasUnitDiskDevice*>(pUnitDeviceNow.get()); if (!HasSameDIBInfo(*pUnitDiskDeviceNow)) { return FALSE; } return TRUE; }
BOOL CNdasDevice::CreateUnitDevice(DWORD dwUnitNo) { _ASSERTE(dwUnitNo < MAX_NDAS_UNITDEVICE_COUNT); if (dwUnitNo >= MAX_NDAS_UNITDEVICE_COUNT) { return FALSE; } _ASSERTE(NULL == m_pUnitDevices[dwUnitNo]); if (!m_fUnitDevicePresent[dwUnitNo]) { DBGPRT_WARN(_FT("HWINFO does not contain unit %d.\n"), dwUnitNo); return FALSE; } DWORD dwMaxFailure = NdasServiceConfig::Get(nscUnitDeviceIdentifyRetryMax); DWORD dwInterval = NdasServiceConfig::Get(nscUnitDeviceIdentifyRetryGap); for (DWORD i = 0; i < dwMaxFailure; ++i) { CNdasUnitDeviceCreator udCreator(*this, dwUnitNo); CNdasUnitDevice* pUnitDevice = udCreator.CreateUnitDevice(); // CreateUnitDevice already called AddRef if (NULL != pUnitDevice) { m_pUnitDevices[dwUnitNo] = pUnitDevice; pUnitDevice->RegisterToLDM(); return TRUE; } ::Sleep(dwInterval); DBGPRT_ERR_EX(_FT("Creating a unit device instance failed (%d out of %d): "), i, dwMaxFailure); } return FALSE; }
BOOL CNdasDevice::CreateUnitDevice(DWORD dwUnitNo) { _ASSERTE(dwUnitNo < MAX_NDAS_UNITDEVICE_COUNT); if (dwUnitNo >= MAX_NDAS_UNITDEVICE_COUNT) { return FALSE; } _ASSERTE(NULL == m_pUnitDevices[dwUnitNo]); if (!m_fUnitDevicePresent[dwUnitNo]) { DBGPRT_WARN(_FT("HWINFO does not contain unit %d.\n"), dwUnitNo); return FALSE; } static const DWORD UNITDEVICE_IDENTIFY_FAILURE_RETRY_DEFAULT = 4; static const DWORD UNITDEVICE_IDENTIFY_INTERVAL_DEFAULT = 2500; DWORD dwMaxFailure = UNITDEVICE_IDENTIFY_FAILURE_RETRY_DEFAULT; BOOL fSuccess = _NdasSystemCfg.GetValueEx( _T("ndassvc"), _T("MaxUnitDeviceIdentifyFailure"), &dwMaxFailure); if (!fSuccess || 0 == dwMaxFailure) { dwMaxFailure = UNITDEVICE_IDENTIFY_FAILURE_RETRY_DEFAULT; } DWORD dwInterval = UNITDEVICE_IDENTIFY_INTERVAL_DEFAULT; fSuccess = _NdasSystemCfg.GetValueEx( _T("ndassvc"), _T("UnitDeviceIdentifyFailureRetryInterval"), &dwInterval); if (!fSuccess || dwInterval > 300000) { dwInterval = UNITDEVICE_IDENTIFY_INTERVAL_DEFAULT; } for (DWORD i = 0; i < dwMaxFailure; ++i) { CNdasUnitDeviceCreator udCreator(*this, dwUnitNo); CNdasUnitDevice* pUnitDevice = udCreator.CreateUnitDevice(); // CreateUnitDevice already called AddRef if (NULL != pUnitDevice) { m_pUnitDevices[dwUnitNo] = pUnitDevice; pUnitDevice->RegisterToLDM(); return TRUE; } ::Sleep(dwInterval); DBGPRT_ERR_EX(_FT("Creating a unit device instance failed (%d out of %d): "), i, dwMaxFailure); } return FALSE; }