+ subs.mutex.Unlock()
+
+ event := c.sendE2TSubscriptionRequest(subs, trans, parentTrans)
+ switch themsg := event.(type) {
+ case *e2ap.E2APSubscriptionResponse:
+ subs.mutex.Lock()
+ subs.SubRespMsg = themsg
+ subs.mutex.Unlock()
+ parentTrans.SendEvent(event, 0)
+ return
+ case *e2ap.E2APSubscriptionFailure:
+ subs.mutex.Lock()
+ subs.SubFailMsg = themsg
+ subs.mutex.Unlock()
+ parentTrans.SendEvent(event, 0)
+ default:
+ xapp.Logger.Info("SUBS-SubReq: internal delete due event(%s) %s", typeofSubsMessage(event), idstring(trans, subs, nil))
+ subs.mutex.Lock()
+ subs.valid = false
+ subs.mutex.Unlock()
+ c.sendE2TSubscriptionDeleteRequest(subs, trans, parentTrans)
+ parentTrans.SendEvent(nil, 0)
+ }
+
+ go c.registry.RemoveFromSubscription(subs, parentTrans, 5*time.Second)
+}
+
+//-------------------------------------------------------------------
+// SUBS DELETE Handling
+//-------------------------------------------------------------------
+
+func (c *Control) handleSubscriptionDelete(subs *Subscription, parentTrans *Transaction) {
+
+ trans := c.tracker.NewTransaction(subs.GetMeid())
+ subs.WaitTransactionTurn(trans)
+ defer subs.ReleaseTransactionTurn(trans)
+ defer trans.Release()
+
+ xapp.Logger.Debug("SUBS-SubDelReq: Handling %s parent %s", idstring(trans, subs, nil), parentTrans.String())
+
+ subs.mutex.Lock()
+ if subs.valid && subs.EpList.HasEndpoint(parentTrans.GetEndpoint()) && subs.EpList.Size() == 1 {
+ subs.valid = false
+ subs.mutex.Unlock()
+ c.sendE2TSubscriptionDeleteRequest(subs, trans, parentTrans)
+ } else {
+ subs.mutex.Unlock()
+ }
+
+ subDelRespMsg := &e2ap.E2APSubscriptionDeleteResponse{}
+ subDelRespMsg.RequestId.Id = subs.SubReqMsg.RequestId.Id
+ subDelRespMsg.RequestId.Seq = uint32(subs.GetSubId())
+ subDelRespMsg.FunctionId = subs.SubReqMsg.FunctionId
+ parentTrans.SendEvent(subDelRespMsg, 0)
+
+ go c.registry.RemoveFromSubscription(subs, parentTrans, 5*time.Second)