Fix USB/IP import lease and attach races
This commit is contained in:
@@ -231,7 +231,7 @@ func writeUsbipSockfd(busid string, fd int) error {
|
||||
return writeSysfs(filepath.Join(sysBusUSBDevices, busid, "usbip_sockfd"), strconv.Itoa(fd))
|
||||
}
|
||||
|
||||
func vhciPickFreePort(speed uint32) (int, error) {
|
||||
func vhciPickFreePort(speed uint32, skip map[int]struct{}) (int, error) {
|
||||
records, err := readVHCIStatus()
|
||||
if err != nil {
|
||||
return -1, err
|
||||
@@ -241,6 +241,9 @@ func vhciPickFreePort(speed uint32) (int, error) {
|
||||
if record.hub != targetHub || record.state != 4 {
|
||||
continue
|
||||
}
|
||||
if _, skipped := skip[record.port]; skipped {
|
||||
continue
|
||||
}
|
||||
return record.port, nil
|
||||
}
|
||||
return -1, E.New("no free ", targetHub, " vhci port")
|
||||
|
||||
Reference in New Issue
Block a user