Transaction needs only subs id.
Change-Id: Iad421b0e03081d52ee96908454e9976cf5229538
Signed-off-by: Juha Hyttinen <juha.hyttinen@nokia.com>
diff --git a/pkg/control/control.go b/pkg/control/control.go
index ff7b19d..2d7d535 100755
--- a/pkg/control/control.go
+++ b/pkg/control/control.go
@@ -188,7 +188,7 @@
return
}
- trans := c.tracker.NewXappTransaction(NewRmrEndpoint(params.Src), params.Xid, &RequestId{subReqMsg.RequestId}, params.Meid)
+ trans := c.tracker.NewXappTransaction(NewRmrEndpoint(params.Src), params.Xid, subReqMsg.RequestId.Seq, params.Meid)
if trans == nil {
xapp.Logger.Error("XAPP-SubReq: %s", idstring(fmt.Errorf("transaction not created"), params))
return
@@ -248,7 +248,7 @@
return
}
- trans := c.tracker.NewXappTransaction(NewRmrEndpoint(params.Src), params.Xid, &RequestId{subDelReqMsg.RequestId}, params.Meid)
+ trans := c.tracker.NewXappTransaction(NewRmrEndpoint(params.Src), params.Xid, subDelReqMsg.RequestId.Seq, params.Meid)
if trans == nil {
xapp.Logger.Error("XAPP-SubDelReq: %s", idstring(fmt.Errorf("transaction not created"), params))
return
@@ -261,7 +261,7 @@
return
}
- subs, err := c.registry.GetSubscriptionFirstMatch([]uint32{subDelReqMsg.RequestId.Seq})
+ subs, err := c.registry.GetSubscriptionFirstMatch([]uint32{trans.GetSubId()})
if err != nil {
xapp.Logger.Error("XAPP-SubDelReq: %s", idstring(err, trans))
return
@@ -277,7 +277,7 @@
// Whatever is received send ok delete response
subDelRespMsg := &e2ap.E2APSubscriptionDeleteResponse{}
- subDelRespMsg.RequestId = subs.SubReqMsg.RequestId
+ subDelRespMsg.RequestId = subs.GetReqId().RequestId
subDelRespMsg.FunctionId = subs.SubReqMsg.FunctionId
trans.Mtype, trans.Payload, err = c.e2ap.PackSubscriptionDeleteResponse(subDelRespMsg)
if err == nil {
@@ -342,10 +342,7 @@
subs.mutex.Unlock()
}
- subDelRespMsg := &e2ap.E2APSubscriptionDeleteResponse{}
- subDelRespMsg.RequestId = subs.SubReqMsg.RequestId
- subDelRespMsg.FunctionId = subs.SubReqMsg.FunctionId
- parentTrans.SendEvent(subDelRespMsg, 0)
+ parentTrans.SendEvent(nil, 0)
}
//-------------------------------------------------------------------
diff --git a/pkg/control/registry.go b/pkg/control/registry.go
index 9cacd94..f24dccd 100644
--- a/pkg/control/registry.go
+++ b/pkg/control/registry.go
@@ -125,7 +125,7 @@
// Find possible existing Policy subscription
//
if actionType == e2ap.E2AP_ActionTypePolicy {
- if subs, ok := r.register[subReqMsg.RequestId.Seq]; ok {
+ if subs, ok := r.register[trans.GetSubId()]; ok {
xapp.Logger.Debug("CREATE %s. Existing subscription for Policy found", subs.String())
subs.SetCachedResponse(nil, true)
return subs, nil
diff --git a/pkg/control/tracker.go b/pkg/control/tracker.go
index 2f54237..cf00af3 100644
--- a/pkg/control/tracker.go
+++ b/pkg/control/tracker.go
@@ -50,10 +50,6 @@
func (t *Tracker) NewSubsTransaction(subs *Subscription) *TransactionSubs {
trans := &TransactionSubs{}
trans.Meid = subs.GetMeid()
- rid := subs.GetReqId()
- if rid != nil {
- trans.ReqId = *rid
- }
t.initTransaction(&trans.Transaction)
xapp.Logger.Debug("CREATE %s", trans.String())
return trans
@@ -62,15 +58,13 @@
func (t *Tracker) NewXappTransaction(
endpoint *RmrEndpoint,
xid string,
- reqId *RequestId,
+ subid uint32,
meid *xapp.RMRMeid) *TransactionXapp {
trans := &TransactionXapp{}
trans.XappKey = &TransactionXappKey{*endpoint, xid}
trans.Meid = meid
- if reqId != nil {
- trans.ReqId = *reqId
- }
+ trans.SubId = subid
t.initTransaction(&trans.Transaction)
xapp.Logger.Debug("CREATE %s", trans.String())
return trans
diff --git a/pkg/control/transaction.go b/pkg/control/transaction.go
index df4d7db..56dff1d 100644
--- a/pkg/control/transaction.go
+++ b/pkg/control/transaction.go
@@ -46,14 +46,13 @@
Seq uint64 //transaction sequence
tracker *Tracker //tracker instance
Meid *xapp.RMRMeid //meid transaction related
- ReqId RequestId //
Mtype int //Encoded message type to be send
Payload *e2ap.PackedData //Encoded message to be send
EventChan chan interface{}
}
func (t *Transaction) String() string {
- return "trans(" + strconv.FormatUint(uint64(t.Seq), 10) + "/" + t.Meid.RanName + "/" + t.ReqId.String() + ")"
+ return "trans(" + strconv.FormatUint(uint64(t.Seq), 10) + "/" + t.Meid.RanName + ")"
}
func (t *Transaction) SendEvent(event interface{}, waittime time.Duration) (bool, bool) {
@@ -83,12 +82,6 @@
return event, false
}
-func (t *Transaction) GetReqId() *RequestId {
- t.mutex.Lock()
- defer t.mutex.Unlock()
- return &t.ReqId
-}
-
func (t *Transaction) GetMtype() int {
t.mutex.Lock()
defer t.mutex.Unlock()
@@ -144,8 +137,9 @@
//
//-----------------------------------------------------------------------------
type TransactionXapp struct {
- Transaction //
- XappKey *TransactionXappKey //
+ Transaction
+ XappKey *TransactionXappKey
+ SubId uint32
}
func (t *TransactionXapp) String() string {
@@ -153,7 +147,7 @@
if t.XappKey != nil {
transkey = t.XappKey.String()
}
- return "transxapp(" + t.Transaction.String() + "/" + transkey + ")"
+ return "transxapp(" + t.Transaction.String() + "/" + transkey + "/" + strconv.FormatUint(uint64(t.SubId), 10) + ")"
}
func (t *TransactionXapp) GetEndpoint() *RmrEndpoint {
@@ -183,6 +177,12 @@
return ""
}
+func (t *TransactionXapp) GetSubId() uint32 {
+ t.mutex.Lock()
+ defer t.mutex.Unlock()
+ return t.SubId
+}
+
func (t *TransactionXapp) Release() {
t.mutex.Lock()
xapp.Logger.Debug("RELEASE %s", t.String())