Fix USB/IP matched retention and snapshot ordering

This commit is contained in:
世界
2026-04-24 23:15:11 +08:00
parent 0e34a2d088
commit 26bd37a012
8 changed files with 199 additions and 24 deletions
+11 -8
View File
@@ -68,12 +68,13 @@ type ClientService struct {
matches []option.USBIPDeviceMatch // empty = import all remote exports
ops usbipOps
stateMu sync.Mutex
targets []clientTarget
assigned []string
assignedWorkers []*clientAssignedWorker
allWorkers map[string]*clientBusIDWorker
allDesired map[string]struct{}
stateMu sync.Mutex
targets []clientTarget
assigned []string
assignedWorkers []*clientAssignedWorker
allWorkers map[string]*clientBusIDWorker
allDesired map[string]struct{}
matchedKnownKeys map[string]DeviceKey
attachMu sync.Mutex // serializes vhci port pick + attach
wg sync.WaitGroup
@@ -425,11 +426,13 @@ func (c *ClientService) applyMatchedExportsWithRetained(entries []DeviceEntry, k
c.stateMu.Unlock()
return
}
activeCurrent := c.activeCurrentAssignmentsLocked(c.assigned, knownKeys)
nextAssigned := assignMatchedBusIDsWithRetained(c.targets, c.assigned, entries, knownKeys, activeCurrent)
assignmentKeys := c.matchedKeysForAssignmentLocked(entries, knownKeys)
activeCurrent := c.activeCurrentAssignmentsLocked(c.assigned, assignmentKeys)
nextAssigned := assignMatchedBusIDsWithRetained(c.targets, c.assigned, entries, assignmentKeys, activeCurrent)
workers := append([]*clientAssignedWorker(nil), c.assignedWorkers...)
previous := append([]string(nil), c.assigned...)
c.assigned = nextAssigned
c.retainMatchedKnownKeysLocked(assignmentKeys, entries, nextAssigned)
c.stateMu.Unlock()
for i, worker := range workers {