[VOL-4525] openonuAdapterGo - reconciling of ONU falls back from status success to falied
[VOL-4533] openonuAdapterGo - sporadically uni ports are missing after reconcile test

Change-Id: I127f1b97c97566dfe8a7ddae220d45a06b8d38e2
diff --git a/internal/pkg/onuadaptercore/mib_sync.go b/internal/pkg/onuadaptercore/mib_sync.go
index 567a3f4..208d8cd 100644
--- a/internal/pkg/onuadaptercore/mib_sync.go
+++ b/internal/pkg/onuadaptercore/mib_sync.go
@@ -321,10 +321,12 @@
 
 		// start go routine with select() on reconciling flow channel before
 		// starting flow reconciling process to prevent loss of any signal
-		go func() {
+		syncChannel := make(chan struct{})
+		go func(aSyncChannel chan struct{}) {
 			// 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.
+			aSyncChannel <- struct{}{}
 			select {
 			case success := <-oo.baseDeviceHandler.chReconcilingFlowsFinished:
 				if success {
@@ -344,7 +346,11 @@
 				oo.baseDeviceHandler.setReconcilingFlows(false)
 				_ = oo.pMibUploadFsm.pFsm.Event(ulEvMismatch)
 			}
-		}()
+		}(syncChannel)
+		// block further processing until the above Go routine has really started
+		// and is ready to receive values from chReconcilingFlowsFinished
+		<-syncChannel
+
 		oo.baseDeviceHandler.reconcileDeviceFlowConfig(ctx)
 
 		oo.mutexPersOnuConfig.RLock()