- 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)
+ subRfMsg, valid := subs.GetCachedResponse()
+ if subRfMsg == nil && valid == true {
+ event := c.sendE2TSubscriptionRequest(subs, trans, parentTrans)
+ switch event.(type) {
+ case *e2ap.E2APSubscriptionResponse:
+ subRfMsg, valid = subs.SetCachedResponse(event, true)
+ case *e2ap.E2APSubscriptionFailure:
+ subRfMsg, valid = subs.SetCachedResponse(event, false)
+ default:
+ xapp.Logger.Info("SUBS-SubReq: internal delete due event(%s) %s", typeofSubsMessage(event), idstring(nil, trans, subs, parentTrans))
+ subRfMsg, valid = subs.SetCachedResponse(nil, false)
+ c.sendE2TSubscriptionDeleteRequest(subs, trans, parentTrans)
+ }
+ xapp.Logger.Debug("SUBS-SubReq: Handling (e2t response %s) %s", typeofSubsMessage(subRfMsg), idstring(nil, trans, subs, parentTrans))
+ } else {
+ xapp.Logger.Debug("SUBS-SubReq: Handling (cached response %s) %s", typeofSubsMessage(subRfMsg), idstring(nil, trans, subs, parentTrans))