Coverity issues fixed
[ric-plt/submgr.git] / pkg / control / registry.go
index 3de549a..f9e1bcc 100644 (file)
@@ -36,7 +36,7 @@ import (
 //-----------------------------------------------------------------------------
 
 type RESTSubscription struct {
-       Created          time.Time
+       Created          string
        xAppServiceName  string
        xAppRmrEndPoint  string
        Meid             string
@@ -233,7 +233,7 @@ func (r *Registry) CreateRESTSubscription(restSubId *string, xappServiceName *st
        r.mutex.Lock()
        defer r.mutex.Unlock()
        newRestSubscription := RESTSubscription{}
-       newRestSubscription.Created = time.Now()
+       newRestSubscription.Created = time.Now().Format("2006-01-02 15:04:05.000")
        newRestSubscription.xAppServiceName = *xappServiceName
        newRestSubscription.xAppRmrEndPoint = *xAppRmrEndPoint
        newRestSubscription.Meid = *maid
@@ -530,7 +530,9 @@ func (r *Registry) RemoveFromSubscription(subs *Subscription, trans *Transaction
        if waitRouteClean > 0 {
                // Wait here that response is delivered to xApp via RMR before route is cleaned
                xapp.Logger.Debug("Pending %v in order to wait route cleanup", waitRouteClean)
+               r.mutex.Unlock()
                time.Sleep(waitRouteClean)
+               r.mutex.Lock()
        }
 
        xapp.Logger.Debug("CLEAN %s", subs.String())
@@ -567,7 +569,10 @@ func (r *Registry) RemoveFromSubscription(subs *Subscription, trans *Transaction
 
                // Endpoint of merged subscription is being deleted
                xapp.Logger.Debug("Subscription route update WriteSubscriptionToDb")
-               c.WriteSubscriptionToDb(subs)
+               err := c.WriteSubscriptionToDb(subs)
+               if err != nil {
+                       xapp.Logger.Error("tracker.UnTrackTransaction() failed:%s", err.Error())
+               }
                c.UpdateCounter(cUnmergedSubscriptions)
        }
        return nil