X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fcontrol%2Fregistry.go;h=9cacd9433333d8da7f528ad379097053533819b1;hb=f44377db11001585180cb1a41452a12bfd44546f;hp=c9abdb8aa0fd535ce4ae5f25f9efa11fad56936c;hpb=9bcb0a4620d71671f758dce029cb2e3da9ab9dbe;p=ric-plt%2Fsubmgr.git diff --git a/pkg/control/registry.go b/pkg/control/registry.go index c9abdb8..9cacd94 100644 --- a/pkg/control/registry.go +++ b/pkg/control/registry.go @@ -217,44 +217,46 @@ func (r *Registry) RemoveFromSubscription(subs *Subscription, trans *Transaction return nil } - r.mutex.Unlock() + go func() { + if waitRouteClean > 0 { + time.Sleep(waitRouteClean) + } - // - // Wait some time before really do route updates - // - if waitRouteClean > 0 { - subs.mutex.Unlock() - time.Sleep(waitRouteClean) subs.mutex.Lock() - } + defer subs.mutex.Unlock() + xapp.Logger.Info("CLEAN %s", subs.String()) - xapp.Logger.Info("CLEAN %s", subs.String()) + if epamount == 0 { + // + // Subscription route delete + // + tmpList := RmrEndpointList{} + tmpList.AddEndpoint(trans.GetEndpoint()) + subRouteAction := SubRouteInfo{tmpList, uint16(seqId)} + r.rtmgrClient.SubscriptionRequestDelete(subRouteAction) - // - // Subscription route updates - // - if epamount == 0 { - tmpList := RmrEndpointList{} - tmpList.AddEndpoint(trans.GetEndpoint()) - subRouteAction := SubRouteInfo{tmpList, uint16(seqId)} - r.rtmgrClient.SubscriptionRequestDelete(subRouteAction) - } else if subs.EpList.Size() > 0 { - subRouteAction := SubRouteInfo{subs.EpList, uint16(seqId)} - r.rtmgrClient.SubscriptionRequestUpdate(subRouteAction) - } + // + // Subscription release + // + r.mutex.Lock() + defer r.mutex.Unlock() - r.mutex.Lock() - // - // If last endpoint, release and free seqid - // - if epamount == 0 { - if _, ok := r.register[seqId]; ok { - xapp.Logger.Debug("RELEASE %s", subs.String()) - delete(r.register, seqId) - xapp.Logger.Debug("Registry: substable=%v", r.register) + if _, ok := r.register[seqId]; ok { + xapp.Logger.Debug("RELEASE %s", subs.String()) + delete(r.register, seqId) + xapp.Logger.Debug("Registry: substable=%v", r.register) + } + r.subIds = append(r.subIds, seqId) + + } else if subs.EpList.Size() > 0 { + // + // Subscription route updates + // + subRouteAction := SubRouteInfo{subs.EpList, uint16(seqId)} + r.rtmgrClient.SubscriptionRequestUpdate(subRouteAction) } - r.subIds = append(r.subIds, seqId) - } + + }() return nil }