Windows: when periodic update of device is disabled, use SetupAPI to list disks on demand instead of testing all disks to reduce CPU usage.

This commit is contained in:
Mounir IDRASSI 2019-09-30 16:08:27 +02:00
parent e3afa296c7
commit 9b804137e0
No known key found for this signature in database
GPG Key ID: 02C30AE90FAE4A6F

View File

@ -12533,7 +12533,7 @@ wstring FindDeviceByVolumeID (const BYTE volumeID [VOLUME_ID_SIZE], BOOL bFromSe
/* not mounted. Look for it in the local drives*/
if (bFromService || !NeedPeriodicDeviceListUpdate)
if (bFromService)
{
for (int devNumber = 0; devNumber < MAX_HOST_DRIVE_NUMBER; devNumber++)
{
@ -12562,6 +12562,8 @@ wstring FindDeviceByVolumeID (const BYTE volumeID [VOLUME_ID_SIZE], BOOL bFromSe
static std::vector<HostDevice> volumeIdCandidates;
EnterCriticalSection (&csMountableDevices);
if (!NeedPeriodicDeviceListUpdate)
UpdateMountableHostDeviceList ();
std::vector<HostDevice> newDevices = mountableDevices;
LeaveCriticalSection (&csMountableDevices);