[VOL-5456] Address memory leak issues when the OMCI transmission fails with rxSupervision on

Change-Id: I14343f577ed83a2932a7f3c6eae34f19fa611f6b
Signed-off-by: pnalmas <praneeth.nalmas@radisys.com>
diff --git a/VERSION b/VERSION
index 9d44043..965c65d 100755
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.12.19
+2.12.20
diff --git a/internal/pkg/common/omci_cc.go b/internal/pkg/common/omci_cc.go
index ab12ef7..265bcab 100755
--- a/internal/pkg/common/omci_cc.go
+++ b/internal/pkg/common/omci_cc.go
@@ -649,6 +649,10 @@
 			// In this case, resend attempts for the message are ensured by our retry
 			// mechanism after omci-timeout.
 			oo.highPrioTxQueue.Remove(queueElement) // Dequeue
+			//Remove the call back from the rxSchedulerMap
+			oo.mutexRxSchedMap.Lock()
+			delete(oo.rxSchedulerMap, queueElement.Value.(OmciTransferStructure).cbPair.CbKey)
+			oo.mutexRxSchedMap.Unlock()
 			return err
 		}
 		oo.highPrioTxQueue.Remove(queueElement) // Dequeue
@@ -670,6 +674,10 @@
 				// mechanism after omci-timeout.
 				oo.lowPrioTxQueue.Remove(queueElement) // Dequeue
 				oo.mutexLowPrioTxQueue.Unlock()
+				//Remove the call back from the rxSchedulerMap
+				oo.mutexRxSchedMap.Lock()
+				delete(oo.rxSchedulerMap, queueElement.Value.(OmciTransferStructure).cbPair.CbKey)
+				oo.mutexRxSchedMap.Unlock()
 				return err
 			}
 		} else {
@@ -681,6 +689,9 @@
 				// mechanism after omci-timeout.
 				oo.lowPrioTxQueue.Remove(queueElement) // Dequeue
 				oo.mutexLowPrioTxQueue.Unlock()
+				oo.mutexRxSchedMap.Lock()
+				delete(oo.rxSchedulerMap, queueElement.Value.(OmciTransferStructure).cbPair.CbKey)
+				oo.mutexRxSchedMap.Unlock()
 				return err
 			}
 		}
@@ -4459,6 +4470,11 @@
 		oo.lowPrioTxQueue.PushBack(aOmciTxRequest)
 		oo.mutexLowPrioTxQueue.Unlock()
 
+		//Register the call back again as we clean up the Map entry when we failed to send the message
+		oo.mutexRxSchedMap.Lock()
+		oo.rxSchedulerMap[aOmciTxRequest.cbPair.CbKey] = aOmciTxRequest.cbPair.CbEntry
+		oo.mutexRxSchedMap.Unlock()
+
 		go oo.sendQueuedRequests(ctx)
 
 		select {
@@ -4982,6 +4998,12 @@
 			oo.lowPrioTxQueue.PushBack(aOmciTxRequest)
 			oo.mutexLowPrioTxQueue.Unlock()
 		}
+
+		//Register the call back again as we clean up the Map entry when we failed to send the message .
+		oo.mutexRxSchedMap.Lock()
+		oo.rxSchedulerMap[aOmciTxRequest.cbPair.CbKey] = aOmciTxRequest.cbPair.CbEntry
+		oo.mutexRxSchedMap.Unlock()
+
 		go oo.sendQueuedRequests(ctx)
 
 		select {