VOL-3646 Fix for removal of DELETED admin state
Change-Id: Icbc4eeeb4185cbe216adfa69d6b0a79597353e15
diff --git a/internal/pkg/core/device_handler.go b/internal/pkg/core/device_handler.go
index cb569d7..229481f 100644
--- a/internal/pkg/core/device_handler.go
+++ b/internal/pkg/core/device_handler.go
@@ -379,10 +379,6 @@
logger.Errorw(ctx, "read-indication-error",
log.Fields{"err": err,
"device-id": dh.device.Id})
- if device.AdminState == voltha.AdminState_DELETED {
- logger.Debug(ctx, "device-deleted--stopping-the-read-indication-thread")
- break Loop
- }
// Close the stream, and re-initialize it
if err = indications.CloseSend(); err != nil {
// Ok to ignore here, because we landed here due to a problem on the stream
@@ -1655,6 +1651,12 @@
dh.stopCollector <- true
// stop the heartbeat check routine
dh.stopHeartbeatCheck <- true
+ dh.lockDevice.RLock()
+ // Stop the read indication only if it the routine is active
+ if dh.isReadIndicationRoutineActive {
+ dh.stopIndications <- true
+ }
+ dh.lockDevice.RUnlock()
//Reset the state
if dh.Client != nil {
if _, err := dh.Client.Reboot(ctx, new(oop.Empty)); err != nil {