Skip to content

Commit

Permalink
devices: fix busy loop
Browse files Browse the repository at this point in the history
If previous devices and new devices are equal, we don't wait for the
invalidation of the query, and run into a busy loop until the devices
change.

Fixes: 03ad61b (datapath/linux: Implement DevicesController)

Signed-off-by: David Bimmler <[email protected]>
  • Loading branch information
bimmlerd authored and julianwiedmann committed Nov 14, 2023
1 parent 01e9612 commit fc8f9ec
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pkg/datapath/linux/devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@ func (dm *DeviceManager) Listen(ctx context.Context) (chan []string, error) {
devices, invalidated := tables.SelectedDevices(dm.params.DeviceTable, rxn)
newDevices := tables.DeviceNames(devices)

if slices.Equal(prevDevices, newDevices) {
continue
}
select {
case devs <- newDevices:
case <-ctx.Done():
return
if !slices.Equal(prevDevices, newDevices) {
select {
case devs <- newDevices:
case <-ctx.Done():
return
}
}

select {
case <-invalidated:
case <-ctx.Done():
Expand Down

0 comments on commit fc8f9ec

Please sign in to comment.