[VOL-5215] - BBSim crash due to concurrent map write when adding or removing flows

Change-Id: Ib7ebf6db38632c10003220cf11e94c141bb84f66
diff --git a/VERSION b/VERSION
index 4a02d2c..c807441 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.16.2
+1.16.3
diff --git a/internal/bbsim/devices/olt.go b/internal/bbsim/devices/olt.go
index 51c0f14..417e316 100644
--- a/internal/bbsim/devices/olt.go
+++ b/internal/bbsim/devices/olt.go
@@ -225,8 +225,12 @@
 		}
 
 		// initialize the resource maps for every PON Ports
+		olt.AllocIDsLock.Lock()
 		olt.AllocIDs[uint32(i)] = make(map[uint32]map[uint32]map[int32]map[uint64]bool)
+		olt.AllocIDsLock.Unlock()
+		olt.GemPortIDsLock.Lock()
 		olt.GemPortIDs[uint32(i)] = make(map[uint32]map[uint32]map[int32]map[uint64]bool)
+		olt.GemPortIDsLock.Unlock()
 
 		p := CreatePonPort(&olt, uint32(i), tech)
 
@@ -286,8 +290,12 @@
 
 	for ponId := range o.Pons {
 		// initialize the resource maps for every PON Ports
+		olt.AllocIDsLock.Lock()
 		olt.AllocIDs[uint32(ponId)] = make(map[uint32]map[uint32]map[int32]map[uint64]bool)
+		olt.AllocIDsLock.Unlock()
+		olt.GemPortIDsLock.Lock()
 		olt.GemPortIDs[uint32(ponId)] = make(map[uint32]map[uint32]map[int32]map[uint64]bool)
+		olt.GemPortIDsLock.Unlock()
 	}
 }
 
@@ -920,8 +928,12 @@
 	pon, _ := o.GetPonById(onu.IntfId)
 
 	// Enable the resource maps for this ONU
+	olt.AllocIDsLock.Lock()
 	olt.AllocIDs[onu.IntfId][onu.OnuId] = make(map[uint32]map[int32]map[uint64]bool)
+	olt.AllocIDsLock.Unlock()
+	olt.GemPortIDsLock.Lock()
 	olt.GemPortIDs[onu.IntfId][onu.OnuId] = make(map[uint32]map[int32]map[uint64]bool)
+	olt.GemPortIDsLock.Unlock()
 
 	_onu, _ := pon.GetOnuBySn(onu.SerialNumber)