[VOL-5555] Fix deadlock between ONU indication and OMCI indication

Change-Id: I79df6430e2f8a74b7fdc370d1461f37f199b79cf
Signed-off-by: bseeniva <balaji.seenivasan@radisys.com>
diff --git a/VERSION b/VERSION
index 8d738d4..3053a1c 100755
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.13.16
+2.13.17
diff --git a/internal/pkg/core/device_handler.go b/internal/pkg/core/device_handler.go
index c1b62dc..e981fd8 100755
--- a/internal/pkg/core/device_handler.go
+++ b/internal/pkg/core/device_handler.go
@@ -368,9 +368,10 @@
 	logger.Debugw(ctx, "inter-adapter-recv-omci", log.Fields{
 		"device-id": dh.DeviceID, "RxOmciMessage": hex.EncodeToString(omciMsg.Message)})
 	*/
-	pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
 	if pDevEntry != nil {
 		if pDevEntry.PDevOmciCC != nil {
+			logger.Debugw(ctx, "pDevEntry.PDevOmciCC is not nil", log.Fields{"device-id": dh.DeviceID})
 			return pDevEntry.PDevOmciCC.ReceiveMessage(log.WithSpanFromContext(context.TODO(), ctx), msg.Message)
 		}
 		logger.Debugw(ctx, "omciCC not ready to receive omci messages - incoming omci message ignored", log.Fields{"device-id": dh.DeviceID,
@@ -383,7 +384,7 @@
 func (dh *deviceHandler) handleTechProfileDownloadRequest(ctx context.Context, techProfMsg *ia.TechProfileDownloadMessage) error {
 	logger.Infow(ctx, "tech-profile-download-request", log.Fields{"device-id": dh.DeviceID})
 
-	pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
 	if pDevEntry == nil {
 		logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
 		return fmt.Errorf("no valid OnuDevice: %s", dh.DeviceID)
@@ -526,7 +527,7 @@
 func (dh *deviceHandler) handleDeleteTcontRequest(ctx context.Context, delTcontMsg *ia.DeleteTcontMessage) error {
 	logger.Infow(ctx, "delete-tcont-request start", log.Fields{"device-id": dh.DeviceID, "uni-id": delTcontMsg.UniId, "tcont": delTcontMsg.AllocId})
 
-	pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
 	if pDevEntry == nil {
 		logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
 		return fmt.Errorf("no valid OnuDevice: %s", dh.DeviceID)
@@ -578,7 +579,7 @@
 
 func (dh *deviceHandler) deleteTechProfileResource(ctx context.Context,
 	uniID uint8, tpID uint8, pathString string, resource avcfg.ResourceEntry, entryID uint32) error {
-	pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
 	if pDevEntry == nil {
 		logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
 		return fmt.Errorf("no valid OnuDevice: %s", dh.DeviceID)
@@ -929,7 +930,7 @@
 
 	continueWithFlowConfig := false
 
-	pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
 	if pDevEntry == nil {
 		logger.Errorw(ctx, "reconciling - no valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
 		dh.stopReconciling(ctx, false, cWaitReconcileFlowNoActivity)
@@ -1059,7 +1060,7 @@
 func (dh *deviceHandler) ReconcileDeviceFlowConfig(ctx context.Context) {
 	logger.Debugw(ctx, "reconciling - trigger flow config", log.Fields{"device-id": dh.DeviceID})
 
-	pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
 	if pDevEntry == nil {
 		logger.Errorw(ctx, "reconciling - no valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
 		dh.stopReconciling(ctx, false, cWaitReconcileFlowNoActivity)
@@ -1657,7 +1658,7 @@
 		"device-id": dh.DeviceID, "image-name": (*apImageDsc).Name})
 
 	var err error
-	pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
 	if pDevEntry == nil {
 		logger.Errorw(ctx, "start Onu SW upgrade rejected: no valid OnuDevice", log.Fields{"device-id": dh.DeviceID})
 		return fmt.Errorf("start Onu SW upgrade rejected: no valid OnuDevice for device-id: %s", dh.DeviceID)
@@ -1708,7 +1709,7 @@
 	apDownloadManager *swupg.FileDownloadManager, aImageIdentifier string) {
 
 	var err error
-	pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
 	if pDevEntry == nil {
 		logger.Errorw(ctx, "start Onu SW upgrade rejected: no valid OnuDevice", log.Fields{"device-id": dh.DeviceID})
 		return
@@ -1780,7 +1781,7 @@
 	//  1.) activation of the image for a started upgrade process (in case the running upgrade runs on the requested image)
 	//  2.) activation of the inactive image
 
-	pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
 	if pDevEntry == nil {
 		logger.Errorw(ctx, "Onu image activation rejected: no valid OnuDevice", log.Fields{"device-id": dh.DeviceID})
 		return nil, fmt.Errorf("no valid OnuDevice for device-id: %s", dh.DeviceID)
@@ -1849,7 +1850,7 @@
 	//  1.) commitment of the image for a started upgrade process (in case the running upgrade runs on the requested image)
 	//  2.) commitment of the active image
 
-	pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
 	if pDevEntry == nil {
 		logger.Errorw(ctx, "Onu image commitment rejected: no valid OnuDevice", log.Fields{"device-id": dh.DeviceID})
 		return nil, fmt.Errorf("no valid OnuDevice for device-id: %s", dh.DeviceID)
@@ -3332,7 +3333,7 @@
 		sFsmName = "UnLockStateFSM"
 	}
 
-	pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
 	if pDevEntry == nil {
 		logger.Errorw(ctx, "No valid OnuDevice -aborting", log.Fields{"device-id": dh.DeviceID})
 		return
@@ -3852,7 +3853,7 @@
 	aMatchVlan uint16, aMatchPcp uint8, aSetVlan uint16, aSetPcp uint8, innerCvlan uint16, aDevEvent cmn.OnuDeviceEvent, lastFlowToReconcile bool, lastFlowToConfOnReboot bool, aMeter *of.OfpMeterConfig, respChan *chan error) error {
 	chVlanFilterFsm := make(chan cmn.Message, 2)
 
-	pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
 	if pDevEntry == nil {
 		logger.Errorw(ctx, "No valid OnuDevice -aborting", log.Fields{"device-id": dh.DeviceID})
 		return fmt.Errorf("no valid OnuDevice for device-id %x - aborting", dh.DeviceID)
@@ -4043,7 +4044,7 @@
 	}
 	logger.Debugw(ctx, "Store or clear persistent UniFlowConfig", log.Fields{"device-id": dh.DeviceID})
 
-	pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
 	if pDevEntry == nil {
 		logger.Errorw(ctx, "No valid OnuDevice - aborting", log.Fields{"device-id": dh.DeviceID})
 		return fmt.Errorf("no valid OnuDevice: %s", dh.DeviceID)
@@ -4091,7 +4092,7 @@
 }
 
 func (dh *deviceHandler) StorePersistentData(ctx context.Context) error {
-	pDevEntry := dh.GetOnuDeviceEntry(ctx, true)
+	pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
 	if pDevEntry == nil {
 		logger.Warnw(ctx, "No valid OnuDevice", log.Fields{"device-id": dh.DeviceID})
 		return fmt.Errorf("no valid OnuDevice: %s", dh.DeviceID)
@@ -4609,7 +4610,7 @@
 				// However, a later refactoring of the functionality remains unaffected.
 				dh.mutexReconcilingFlag.Lock()
 				if success {
-					if onuDevEntry := dh.GetOnuDeviceEntry(ctx, true); onuDevEntry == nil {
+					if onuDevEntry := dh.GetOnuDeviceEntry(ctx, false); onuDevEntry == nil {
 						logger.Errorw(ctx, "No valid OnuDevice - aborting Core DeviceStateUpdate",
 							log.Fields{"device-id": dh.DeviceID})
 					} else if !onuDevEntry.SOnuPersistentData.PersRebootInProgress {
@@ -4645,7 +4646,7 @@
 					logger.Errorw(ctx, "wait for reconciling aborted",
 						log.Fields{"device-id": dh.DeviceID})
 
-					if onuDevEntry := dh.GetOnuDeviceEntry(ctx, true); onuDevEntry == nil {
+					if onuDevEntry := dh.GetOnuDeviceEntry(ctx, false); onuDevEntry == nil {
 						logger.Errorw(ctx, "No valid OnuDevice",
 							log.Fields{"device-id": dh.DeviceID})
 					} else {
@@ -4662,7 +4663,7 @@
 					log.Fields{"device-id": dh.DeviceID})
 				dh.mutexReconcilingFlag.Lock()
 
-				if onuDevEntry := dh.GetOnuDeviceEntry(ctx, true); onuDevEntry == nil {
+				if onuDevEntry := dh.GetOnuDeviceEntry(ctx, false); onuDevEntry == nil {
 					logger.Errorw(ctx, "No valid OnuDevice",
 						log.Fields{"device-id": dh.DeviceID})
 				} else {
@@ -4681,7 +4682,7 @@
 			dh.SetReconcilingReasonUpdate(false)
 			dh.SetReconcilingFirstPass(true)
 
-			if onuDevEntry := dh.GetOnuDeviceEntry(ctx, true); onuDevEntry == nil {
+			if onuDevEntry := dh.GetOnuDeviceEntry(ctx, false); onuDevEntry == nil {
 				logger.Errorw(ctx, "No valid OnuDevice", log.Fields{"device-id": dh.DeviceID})
 			} else {
 				onuDevEntry.MutexReconciledTpInstances.Lock()