[VOL-4067] : Fix mechanism used for closing PM collector, alarm manager
and self test handler module routines
Change-Id: Iec97d3a114191b15e00698b35da47555a9359935
diff --git a/internal/pkg/onuadaptercore/omci_self_test_handler.go b/internal/pkg/onuadaptercore/omci_self_test_handler.go
index 2e968fb..ce82db8 100644
--- a/internal/pkg/onuadaptercore/omci_self_test_handler.go
+++ b/internal/pkg/onuadaptercore/omci_self_test_handler.go
@@ -64,7 +64,9 @@
selfTestFsmMap map[generated.ClassID]*fsmCb // The fsmCb is indexed by ME Class ID of the Test Action procedure
selfTestFsmLock sync.RWMutex
- stopSelfTestModule chan bool
+ selfTestHandlerLock sync.RWMutex
+ selfTestHandlerActive bool
+ stopSelfTestModule chan bool
}
// newSelfTestMsgHandlerCb creates the selfTestControlBlock
@@ -342,8 +344,9 @@
}
func (selfTestCb *selfTestControlBlock) waitForStopSelfTestModuleSignal(ctx context.Context) {
-
+ selfTestCb.SetSelfTestHandlerIsRunning(true)
<-selfTestCb.stopSelfTestModule // block on stop signal
+ selfTestCb.SetSelfTestHandlerIsRunning(false)
logger.Infow(ctx, "received stop signal - clean up start", log.Fields{"device-id": selfTestCb.deviceID})
selfTestCb.selfTestFsmLock.Lock()
@@ -363,6 +366,20 @@
//// Exported functions
+// SetSelfTestHandlerActive sets the value to selfTestCb.selfTestHandlerActive
+func (selfTestCb *selfTestControlBlock) SetSelfTestHandlerIsRunning(active bool) {
+ selfTestCb.selfTestHandlerLock.Lock()
+ defer selfTestCb.selfTestHandlerLock.Unlock()
+ selfTestCb.selfTestHandlerActive = active
+}
+
+// GetSelfTestHandlerActive gets selfTestCb.selfTestHandlerActive
+func (selfTestCb *selfTestControlBlock) GetSelfTestHandlerIsRunning() bool {
+ selfTestCb.selfTestHandlerLock.RLock()
+ defer selfTestCb.selfTestHandlerLock.RUnlock()
+ return selfTestCb.selfTestHandlerActive
+}
+
// selfTestRequest initiate Test Request handling procedure. The results are asynchronously conveyed on the respChan.
// If the return from selfTestRequest is NOT nil, the caller shall not wait for async response.
func (selfTestCb *selfTestControlBlock) SelfTestRequestStart(ctx context.Context, reqMsg extension.SingleGetValueRequest, commChan chan Message, respChan chan extension.SingleGetValueResponse) error {