[VOL-4469] Onu adapter reconcilement may stuck on VLAN processing, especially in TT traffic scenarios

Signed-off-by: mpagenko <michael.pagenkopf@adtran.com>
Change-Id: If321388c67e2e52eb04b8a55167eb3c1c7575e5d
diff --git a/internal/pkg/mib/mib_sync.go b/internal/pkg/mib/mib_sync.go
index d3b3543..f36cf9d 100755
--- a/internal/pkg/mib/mib_sync.go
+++ b/internal/pkg/mib/mib_sync.go
@@ -333,25 +333,25 @@
 			// In multi-ONU/multi-flow environment stopping reconcilement has to be delayed until
 			// we get a signal that the processing of the last step to rebuild the adapter internal
 			// flow data is finished.
+			expiry := oo.baseDeviceHandler.GetReconcileExpiryVlanConfigAbort()
+			oo.setReconcilingFlows(true)
 			select {
 			case success := <-oo.chReconcilingFlowsFinished:
 				if success {
 					logger.Debugw(ctx, "reconciling flows has been finished in time",
 						log.Fields{"device-id": oo.deviceID})
-					oo.baseDeviceHandler.StopReconciling(ctx, true)
 					_ = oo.PMibUploadFsm.PFsm.Event(UlEvSuccess)
 
 				} else {
 					logger.Debugw(ctx, "wait for reconciling flows aborted",
 						log.Fields{"device-id": oo.deviceID})
-					oo.SetReconcilingFlows(false)
 				}
-			case <-time.After(500 * time.Millisecond):
+			case <-time.After(expiry):
 				logger.Errorw(ctx, "timeout waiting for reconciling flows to be finished!",
-					log.Fields{"device-id": oo.deviceID})
-				oo.SetReconcilingFlows(false)
+					log.Fields{"device-id": oo.deviceID, "expiry": expiry})
 				_ = oo.PMibUploadFsm.PFsm.Event(UlEvMismatch)
 			}
+			oo.setReconcilingFlows(false)
 		}()
 		oo.baseDeviceHandler.ReconcileDeviceFlowConfig(ctx)
 
@@ -1120,11 +1120,8 @@
 //CancelProcessing terminates potentially running reconciling processes and stops the FSM
 func (oo *OnuDeviceEntry) CancelProcessing(ctx context.Context) {
 
-	if oo.IsReconcilingFlows() {
-		oo.chReconcilingFlowsFinished <- false
-	}
-	if oo.baseDeviceHandler.IsReconciling() {
-		oo.baseDeviceHandler.StopReconciling(ctx, false)
+	if oo.isReconcilingFlows() {
+		oo.SendChReconcilingFlowsFinished(false)
 	}
 	//the MibSync FSM might be active all the ONU-active time,
 	// hence it must be stopped unconditionally