Skip to content

Commit

Permalink
[VOL-4686] openonuAdapterGo: Panic during memory leak test
Browse files Browse the repository at this point in the history
Change-Id: Id37ec3d5eaf579e926c913b1f15d5a9c0ca09bb9
  • Loading branch information
hhildebrandt committed Mar 25, 2022
1 parent 81b5ccf commit 12609a1
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
2.2.2
2.2.3-dev279
1 change: 1 addition & 0 deletions internal/pkg/avcfg/omci_ani_config.go
Expand Up @@ -264,6 +264,7 @@ func (oFsm *UniPonAniConfigFsm) setFsmCompleteChannel(aChSuccess chan<- uint8, a

//CancelProcessing ensures that suspended processing at waiting on some response is aborted and reset of FSM
func (oFsm *UniPonAniConfigFsm) CancelProcessing(ctx context.Context) {
logger.Debugw(ctx, "CancelProcessing entered", log.Fields{"device-id": oFsm.deviceID})
//early indication about started reset processing
oFsm.pUniTechProf.setProfileResetting(ctx, oFsm.pOnuUniPort.UniID, oFsm.techProfileID, true)
//mutex protection is required for possible concurrent access to FSM members
Expand Down
1 change: 1 addition & 0 deletions internal/pkg/avcfg/omci_vlan_config.go
Expand Up @@ -354,6 +354,7 @@ func (oFsm *UniVlanConfigFsm) initUniFlowParams(ctx context.Context, aTpID uint8

//CancelProcessing ensures that suspended processing at waiting on some response is aborted and reset of FSM
func (oFsm *UniVlanConfigFsm) CancelProcessing(ctx context.Context) {
logger.Debugw(ctx, "CancelProcessing entered", log.Fields{"device-id": oFsm.deviceID})
if oFsm == nil {
logger.Error(ctx, "no valid UniVlanConfigFsm!")
return
Expand Down
7 changes: 5 additions & 2 deletions internal/pkg/common/omci_cc.go
Expand Up @@ -4790,14 +4790,17 @@ loop:

//CancelRequestMonitoring terminates monitoring of outstanding omci requests
func (oo *OmciCC) CancelRequestMonitoring(ctx context.Context) {
logger.Debugw(ctx, "CancelRequestMonitoring entered", log.Fields{"device-id": oo.deviceID})
oo.mutexMonReq.RLock()
for k := range oo.monitoredRequests {
//implement non-blocking channel send to avoid blocking on mutexMonReq later
select {
case oo.monitoredRequests[k].chSuccess <- false:
logger.Debugw(ctx, "send cancellation on omciRespChannel",
log.Fields{"index": k, "device-id": oo.deviceID})
default:
logger.Debugw(ctx, "cancel not send on omciRespChannel (no receiver)", log.Fields{
"index": k, "device-id": oo.deviceID})
logger.Debugw(ctx, "cancellation could not be send on omciRespChannel (no receiver)",
log.Fields{"index": k, "device-id": oo.deviceID})
}
}
oo.mutexMonReq.RUnlock()
Expand Down
13 changes: 12 additions & 1 deletion internal/pkg/core/device_handler.go
Expand Up @@ -2200,6 +2200,7 @@ func (dh *deviceHandler) resetFsms(ctx context.Context, includingMibSyncFsm bool
//it is not sufficient to stop/reset the latest running FSM as done in previous versions
// as after down/up procedures all FSM's might be active/ongoing (in theory)
// and using the stop/reset event should never harm
logger.Debugw(ctx, "resetFsms entered", log.Fields{"device-id": dh.DeviceID})

pDevEntry := dh.GetOnuDeviceEntry(ctx, false)
if pDevEntry == nil {
Expand Down Expand Up @@ -4530,7 +4531,17 @@ func (dh *deviceHandler) PrepareForGarbageCollection(ctx context.Context, aDevic
// Note: This function must be called as a goroutine to prevent blocking of further processing!
// first let the objects rest for some time to give all asynchronously started
// cleanup routines a chance to come to an end
time.Sleep(5 * time.Second)
time.Sleep(2 * time.Second)

if dh.pOnuOmciDevice != nil {
if dh.pOnuOmciDevice.PDevOmciCC != nil {
// Since we cannot rule out that one of the handlers had initiated any OMCI configurations during its
// reset handling (even in future coding), request monitoring is canceled here one last time to
// be sure that all corresponding go routines are terminated
dh.pOnuOmciDevice.PDevOmciCC.CancelRequestMonitoring(ctx)
}
}
time.Sleep(3 * time.Second)

if dh.pOnuTP != nil {
dh.pOnuTP.PrepareForGarbageCollection(ctx, aDeviceID)
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/mib/mib_sync.go
Expand Up @@ -1303,7 +1303,7 @@ func (oo *OnuDeviceEntry) getAllStoredTpInstFromParentAdapter(ctx context.Contex

//CancelProcessing terminates potentially running reconciling processes and stops the FSM
func (oo *OnuDeviceEntry) CancelProcessing(ctx context.Context) {

logger.Debugw(ctx, "CancelProcessing entered", log.Fields{"device-id": oo.deviceID})
if oo.isReconcilingFlows() {
oo.SendChReconcilingFlowsFinished(ctx, false)
}
Expand Down
1 change: 1 addition & 0 deletions internal/pkg/swupg/omci_onu_upgrade.go
Expand Up @@ -531,6 +531,7 @@ func (oFsm *OnuUpgradeFsm) SetImageStateActive(ctx context.Context) {
func (oFsm *OnuUpgradeFsm) CancelProcessing(ctx context.Context, abCompleteAbort bool,
aReason voltha.ImageState_ImageFailureReason) {
pAdaptFsm := oFsm.PAdaptFsm
logger.Debugw(ctx, "CancelProcessing entered", log.Fields{"device-id": oFsm.deviceID})
if pAdaptFsm == nil || pAdaptFsm.PFsm == nil {
logger.Warnw(ctx, "OnuUpgradeFsm cancel, but FSM invalid", log.Fields{
"device-id": oFsm.deviceID})
Expand Down
1 change: 1 addition & 0 deletions internal/pkg/swupg/onu_image_status.go
Expand Up @@ -297,6 +297,7 @@ func (oo *OnuImageStatus) isWaitingForResp() bool {

//CancelProcessing ensures that interrupted processing is canceled while waiting for a response
func (oo *OnuImageStatus) CancelProcessing(ctx context.Context) {
logger.Debugw(ctx, "CancelProcessing entered", log.Fields{"device-id": oo.deviceID})
if oo.isWaitingForResp() {
abortMsg := cmn.Message{
Type: cmn.TestMsg,
Expand Down

0 comments on commit 12609a1

Please sign in to comment.