Avoid stale omci_cc send processing due to concurrent channel write (correction sporadic ONU-soft-reboot issues)
Signed-off-by: mpagenko <michael.pagenkopf@adtran.com>
Change-Id: If6161eeda68d60ab802ab95d2d724700c9baa02f
diff --git a/VERSION b/VERSION
index aef3aa9..3c30732 100755
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.3.2-dev211
+1.3.2-dev212
diff --git a/internal/pkg/onuadaptercore/device_handler.go b/internal/pkg/onuadaptercore/device_handler.go
index 59d3236..00cc09b 100644
--- a/internal/pkg/onuadaptercore/device_handler.go
+++ b/internal/pkg/onuadaptercore/device_handler.go
@@ -1981,7 +1981,7 @@
return fmt.Errorf("no valid OnuDevice: %s", dh.deviceID)
}
if pDevEntry.PDevOmciCC != nil {
- pDevEntry.PDevOmciCC.CancelRequestMonitoring()
+ pDevEntry.PDevOmciCC.CancelRequestMonitoring(ctx)
}
pDevEntry.mutexOnuImageStatus.RLock()
if pDevEntry.pOnuImageStatus != nil {
diff --git a/internal/pkg/onuadaptercore/omci_cc.go b/internal/pkg/onuadaptercore/omci_cc.go
index fd93109..edeab97 100644
--- a/internal/pkg/onuadaptercore/omci_cc.go
+++ b/internal/pkg/onuadaptercore/omci_cc.go
@@ -171,7 +171,7 @@
func (oo *omciCC) stop(ctx context.Context) error {
logger.Debugw(ctx, "omciCC-stopping", log.Fields{"device-id": oo.deviceID})
//reseting all internal data, which might also be helpful for discarding any lingering tx/rx requests
- oo.CancelRequestMonitoring()
+ oo.CancelRequestMonitoring(ctx)
oo.mutexTxQueue.Lock()
oo.txQueue.Init() // clear the tx queue
oo.mutexTxQueue.Unlock()
@@ -677,7 +677,13 @@
}
oo.mutexMonReq.RLock()
if _, exist := oo.monitoredRequests[omciMsg.TransactionID]; exist {
- oo.monitoredRequests[omciMsg.TransactionID].chSuccess <- true
+ //implement non-blocking channel send to avoid blocking on mutexMonReq later
+ select {
+ case oo.monitoredRequests[omciMsg.TransactionID].chSuccess <- true:
+ default:
+ logger.Debugw(ctx, "response not send on omciRespChannel (no receiver)", log.Fields{
+ "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
+ }
} else {
logger.Infow(ctx, "reqMon: map entry does not exist!",
log.Fields{"tid": omciMsg.TransactionID, "device-id": oo.deviceID})
@@ -3080,10 +3086,16 @@
}
//CancelRequestMonitoring terminates monitoring of outstanding omci requests
-func (oo *omciCC) CancelRequestMonitoring() {
+func (oo *omciCC) CancelRequestMonitoring(ctx context.Context) {
oo.mutexMonReq.RLock()
for k := range oo.monitoredRequests {
- oo.monitoredRequests[k].chSuccess <- false
+ //implement non-blocking channel send to avoid blocking on mutexMonReq later
+ select {
+ case oo.monitoredRequests[k].chSuccess <- false:
+ default:
+ logger.Debugw(ctx, "cancel not send on omciRespChannel (no receiver)", log.Fields{
+ "index": k, "device-id": oo.deviceID})
+ }
}
oo.mutexMonReq.RUnlock()
}