VOL-2867 - Removed unnescessary proto.Clone() in getDevice() and getLogicalDevice().
Also renamed getDevice() to getDeviceReadOnly(), getLogicalDevice() to getLogicalDeviceReadOnly(), and getDeviceReadOnly() to getDeviceReadOnlyWithoutLock().
Callers of *ReadOnly() functions must not modify the returned structures.
Also fixed places where lock was not acquired before calling getDevice().
Related to VOL-3356.
Change-Id: I9913a76a497c4d977457edaea3b199a24a3a5cb8
diff --git a/rw_core/core/device/logical_manager.go b/rw_core/core/device/logical_manager.go
index cf2beed..ec4a528 100644
--- a/rw_core/core/device/logical_manager.go
+++ b/rw_core/core/device/logical_manager.go
@@ -90,7 +90,7 @@
func (ldMgr *LogicalManager) GetLogicalDevice(ctx context.Context, id *voltha.ID) (*voltha.LogicalDevice, error) {
logger.Debugw(ctx, "getlogicalDevice", log.Fields{"logicaldeviceid": id})
if agent := ldMgr.getLogicalDeviceAgent(ctx, id.Id); agent != nil {
- return agent.GetLogicalDevice(ctx)
+ return agent.GetLogicalDeviceReadOnly(ctx)
}
return nil, status.Errorf(codes.NotFound, "%s", id)
}
@@ -273,7 +273,7 @@
// Get the device
var device *voltha.Device
var err error
- if device, err = ldMgr.deviceMgr.getDevice(ctx, deviceID); err != nil {
+ if device, err = ldMgr.deviceMgr.getDeviceReadOnly(ctx, deviceID); err != nil {
return nil, err
}
return ldMgr.getLogicalDeviceID(ctx, device)