DevMgr: Add attachAllUnattachedDevicesFromKnownListReq
This function is the backbone for the DeviceReattacher daemon. It assembles a list of all DA specs which are known to Mrntt, but which haven't been successfully attached as yet, and attempts to attach them.
This commit is contained in:
@@ -584,6 +584,38 @@ void DeviceManager::attachAllUnattachedDevicesFromCmdlineReq(
|
||||
attachAllUnattachedDevicesFromReq(specs, std::move(cb));
|
||||
}
|
||||
|
||||
void DeviceManager::attachAllUnattachedDevicesFromKnownListReq(
|
||||
Callback<attachAllUnattachedDevicesFromReqCbFn> cb
|
||||
)
|
||||
{
|
||||
// Create a vector to hold unattached device specs
|
||||
auto unattachedSpecs = std::make_shared<std::vector<DeviceAttachmentSpec>>();
|
||||
|
||||
// Cycle through all DA specs in deviceAttachmentSpecs
|
||||
for (const auto& spec : deviceAttachmentSpecs)
|
||||
{
|
||||
bool isAttached = false;
|
||||
|
||||
// Cross reference with attachedDeviceRoles
|
||||
for (const auto& role : attachedDeviceRoles)
|
||||
{
|
||||
if (*role->deviceAttachmentSpec == *spec)
|
||||
{
|
||||
isAttached = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If spec doesn't appear in attachedDeviceRoles, add it to the vector
|
||||
if (!isAttached) {
|
||||
unattachedSpecs->push_back(*spec);
|
||||
}
|
||||
}
|
||||
|
||||
// Pass the vector to the existing function
|
||||
attachAllUnattachedDevicesFromReq(unattachedSpecs, std::move(cb));
|
||||
}
|
||||
|
||||
class DeviceManager::DetachAllAttachedDeviceRoles
|
||||
: public PostedAsynchronousContinuation<
|
||||
detachAllAttachedDeviceRolesCbFn>
|
||||
|
||||
Reference in New Issue
Block a user