fix driver rebinding
This commit is contained in:
@@ -276,17 +276,28 @@ func (sm *ShareManager) handleReleaseDevice(busID, fromClient string) {
|
||||
return
|
||||
}
|
||||
|
||||
// Clean up tunnel
|
||||
// Close the tunnel pipe to signal HandleConnection to stop reading
|
||||
var tunnelDone <-chan struct{}
|
||||
if tunnel, ok := sm.tunnels[share.tunnelID]; ok {
|
||||
tunnel.inPipe.Close()
|
||||
tunnelDone = tunnel.done
|
||||
delete(sm.tunnels, share.tunnelID)
|
||||
}
|
||||
|
||||
// Detach device (release interfaces, reconnect kernel driver)
|
||||
share.server.Detach()
|
||||
server := share.server
|
||||
delete(sm.active, busID)
|
||||
sm.mu.Unlock()
|
||||
|
||||
// Wait for HandleConnection goroutine to finish before detaching.
|
||||
// This ensures no more URBs are being submitted when we detach.
|
||||
if tunnelDone != nil {
|
||||
<-tunnelDone
|
||||
log.Printf("[share] HandleConnection goroutine finished for %s", busID)
|
||||
}
|
||||
|
||||
// Now safe to detach - no more USB/IP protocol processing
|
||||
server.Detach()
|
||||
|
||||
// Notify client
|
||||
sm.client.SendJSON(&protocol.DeviceReleased{
|
||||
Type: protocol.MsgDeviceReleased,
|
||||
|
||||
Reference in New Issue
Block a user