Skip to content

Commit

Permalink
fix(usbdevice): close closed channel exception
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Yu <jack.yu@suse.com>
  • Loading branch information
Yu-Jack committed Jul 31, 2024
1 parent 6a90910 commit cfe1f77
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/deviceplugins/usb_device_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (plugin *USBDevicePlugin) stopDevicePlugin() error {
}

func (plugin *USBDevicePlugin) startDevicePlugin() error {
plugin.deregistered = make(chan struct{})
plugin.deregistered = make(chan struct{}, 1)

err := plugin.cleanup()
if err != nil {
Expand Down Expand Up @@ -310,7 +310,12 @@ func (plugin *USBDevicePlugin) ListAndWatch(_ *pluginapi.Empty, lws pluginapi.De
plugin.logger.Reason(err).Warningf("Failed to deregister device plugin %s",
plugin.resourceName)
}
close(plugin.deregistered)

select {
case plugin.deregistered <- struct{}{}:
default:
}

return nil
}

Expand Down

0 comments on commit cfe1f77

Please sign in to comment.