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/agent_port.go b/rw_core/core/device/agent_port.go
index 5ac7aca..2840235 100644
--- a/rw_core/core/device/agent_port.go
+++ b/rw_core/core/device/agent_port.go
@@ -118,7 +118,7 @@
func (agent *Agent) deleteAllPorts(ctx context.Context) error {
logger.Debugw(ctx, "deleteAllPorts", log.Fields{"deviceId": agent.deviceID})
- device, err := agent.getDevice(ctx)
+ device, err := agent.getDeviceReadOnly(ctx)
if err != nil {
return err
}
@@ -238,7 +238,7 @@
}
//send request to adapter
- device, err := agent.getDevice(ctx)
+ device, err := agent.getDeviceReadOnly(ctx)
if err != nil {
return err
}
@@ -274,7 +274,7 @@
}
//send request to adapter
- device, err := agent.getDevice(ctx)
+ device, err := agent.getDeviceReadOnly(ctx)
if err != nil {
return err
}