xAdded lock around the use of OnuOmciStateMap to prevent a concurrent map write issue.
I considered using a structure like sync.Map or other concurrency safe map, but those don't offer type safety like the built in map object.
Added some missing licensing and a VERSION file as Jenkins is requiring it.
Change-Id: I755709ab4678da12c7585824074a1877f98a5ea1
diff --git a/omci_handlers.go b/omci_handlers.go
index c766c1a..67a57e7 100644
--- a/omci_handlers.go
+++ b/omci_handlers.go
@@ -46,6 +46,7 @@
"IntfId": key.IntfId,
"OnuId": key.OnuId,
}).Tracef("Omci MibReset")
+ OnuOmciStateMapLock.RLock()
if state, ok := OnuOmciStateMap[key]; ok {
log.WithFields(log.Fields{
"IntfId": key.IntfId,
@@ -53,6 +54,7 @@
}).Tracef("Reseting OnuOmciState")
state.ResetOnuOmciState()
}
+ OnuOmciStateMapLock.RUnlock()
pkt = []byte{
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
@@ -88,9 +90,9 @@
func mibUploadNext(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
var pkt []byte
-
+ OnuOmciStateMapLock.RLock()
state := OnuOmciStateMap[key]
-
+ OnuOmciStateMapLock.RUnlock()
// commandNumber is the "Command number" attribute received in "MIB Upload Next" OMCI message
commandNumber := (uint16(content[1])) | (uint16(content[0])<<8)
log.WithFields(log.Fields{
@@ -407,6 +409,8 @@
var pkt []byte
if class == GEMPortNetworkCTP {
+ OnuOmciStateMapLock.RLock()
+ defer OnuOmciStateMapLock.RUnlock()
if onuOmciState, ok := OnuOmciStateMap[key]; !ok {
log.WithFields(log.Fields{
"IntfId": key.IntfId,