X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fcontrol%2Fregistry.go;h=7ad54c16143572149e6ada308e7abf2a208fc962;hb=2f26fb2885e2afda0c2908acbdf923ca63a1fbc6;hp=9e4eaaa6c2235d2cf507e6f1b0bc4662a66de9ea;hpb=17152b256fbffde555fd9ee00a602b897b804ee5;p=ric-plt%2Fsubmgr.git diff --git a/pkg/control/registry.go b/pkg/control/registry.go index 9e4eaaa..7ad54c1 100644 --- a/pkg/control/registry.go +++ b/pkg/control/registry.go @@ -87,7 +87,7 @@ func (r *Registry) allocateSubs(trans *TransactionXapp, subReqMsg *e2ap.E2APSubs return nil, fmt.Errorf("Registry: Failed to reserve subscription no free ids") } -func (r *Registry) findExistingSubs(trans *TransactionXapp, subReqMsg *e2ap.E2APSubscriptionRequest) *Subscription { +func (r *Registry) findExistingSubs(trans *TransactionXapp, subReqMsg *e2ap.E2APSubscriptionRequest) (*Subscription, bool) { for _, subs := range r.register { if subs.IsMergeable(trans, subReqMsg) { @@ -106,18 +106,19 @@ func (r *Registry) findExistingSubs(trans *TransactionXapp, subReqMsg *e2ap.E2AP subs.mutex.Unlock() continue } - // try to add to endpointlist. + // Try to add to endpointlist. Adding fails if endpoint is already in the list if subs.EpList.AddEndpoint(trans.GetEndpoint()) == false { subs.mutex.Unlock() - continue + xapp.Logger.Debug("Registry: Subs with requesting endpoint found. %s for %s", subs.String(), trans.String()) + return subs, true } subs.mutex.Unlock() - xapp.Logger.Debug("Registry: Mergeable subs found %s for %s", subs.String(), trans.String()) - return subs + xapp.Logger.Debug("Registry: Mergeable subs found. %s for %s", subs.String(), trans.String()) + return subs, false } } - return nil + return nil, false } func (r *Registry) AssignToSubscription(trans *TransactionXapp, subReqMsg *e2ap.E2APSubscriptionRequest) (*Subscription, error) { @@ -140,7 +141,7 @@ func (r *Registry) AssignToSubscription(trans *TransactionXapp, subReqMsg *e2ap. // if actionType == e2ap.E2AP_ActionTypePolicy { if subs, ok := r.register[trans.GetSubId()]; ok { - xapp.Logger.Debug("CREATE %s. Existing subscription for Policy found", subs.String()) + xapp.Logger.Debug("CREATE %s. Existing subscription for Policy found.", subs.String()) // Update message data to subscription subs.SubReqMsg = subReqMsg subs.SetCachedResponse(nil, true) @@ -148,13 +149,18 @@ func (r *Registry) AssignToSubscription(trans *TransactionXapp, subReqMsg *e2ap. } } - subs := r.findExistingSubs(trans, subReqMsg) + subs, endPointFound := r.findExistingSubs(trans, subReqMsg) if subs == nil { subs, err = r.allocateSubs(trans, subReqMsg) if err != nil { return nil, err } newAlloc = true + } else if endPointFound == true { + // Requesting endpoint is already present in existing subscription. This can happen if xApp is restarted. + xapp.Logger.Debug("CREATE: subscription already exists. %s", subs.String()) + xapp.Logger.Debug("Registry: substable=%v", r.register) + return subs, nil } //