Skip to content

Commit

Permalink
fix - don't use device after release
Browse files Browse the repository at this point in the history
  • Loading branch information
jkralik committed Apr 29, 2022
1 parent 3f13773 commit c41d4c6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions client/getDevice.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ func (c *Client) GetRefDeviceByIP(
}
links, err := getLinksRefDevice(ctx, refDev, c.disableUDPEndpoints)
if err != nil {
deviceID := refDev.DeviceID()
refDev.Device().Close(ctx)
c.deviceCache.RemoveDevice(ctx, refDev.DeviceID(), refDev)
c.deviceCache.RemoveDevice(ctx, deviceID, refDev)
refDev.Release(ctx)
return nil, nil, fmt.Errorf("cannot get links for device %v: %w", refDev.DeviceID(), err)
return nil, nil, fmt.Errorf("cannot get links for device %v: %w", deviceID, err)
}
return refDev, patchResourceLinksEndpoints(links, c.disableUDPEndpoints), nil
}
Expand Down

0 comments on commit c41d4c6

Please sign in to comment.