Fix for subscription fail handling
[ric-plt/submgr.git] / pkg / control / control.go
index 6111c63..ac142eb 100755 (executable)
@@ -360,8 +360,7 @@ func (c *Control) handleXAPPSubscriptionRequest(params *xapp.RMRParams) {
        }
        defer trans.Release()
 
-       err = c.tracker.Track(trans)
-       if err != nil {
+       if err = c.tracker.Track(trans); err != nil {
                xapp.Logger.Error("XAPP-SubReq: %s", idstring(err, trans))
                return
        }
@@ -373,12 +372,17 @@ func (c *Control) handleXAPPSubscriptionRequest(params *xapp.RMRParams) {
                return
        }
 
-       //
-       // Wake subs request
-       //
+       c.wakeSubscriptionRequest(subs, trans)
+}
+
+//-------------------------------------------------------------------
+// Wake Subscription Request to E2node
+//------------------------------------------------------------------
+func (c *Control) wakeSubscriptionRequest(subs *Subscription, trans *TransactionXapp) {
+
        go c.handleSubscriptionCreate(subs, trans)
        event, _ := trans.WaitEvent(0) //blocked wait as timeout is handled in subs side
-       err = nil
+       var err error
        if event != nil {
                switch themsg := event.(type) {
                case *e2ap.E2APSubscriptionResponse:
@@ -488,8 +492,7 @@ func (c *Control) handleSubscriptionCreate(subs *Subscription, parentTrans *Tran
                case *e2ap.E2APSubscriptionFailure:
                        removeSubscriptionFromDb = true
                        subRfMsg, valid = subs.SetCachedResponse(event, false)
-                       xapp.Logger.Info("SUBS-SubReq: internal delete  due event(%s) %s", typeofSubsMessage(event), idstring(nil, trans, subs, parentTrans))
-                       c.sendE2TSubscriptionDeleteRequest(subs, trans, parentTrans)
+                       xapp.Logger.Info("SUBS-SubReq: internal delete due event(%s) %s", typeofSubsMessage(event), idstring(nil, trans, subs, parentTrans))
                case *SubmgrRestartTestEvent:
                        // This simulates that no response has been received and after restart subscriptions are restored from db
                        xapp.Logger.Debug("Test restart flag is active. Dropping this transaction to test restart case")