From e3f5b2f264b2b5e994c05159eeb1daabf51ab664 Mon Sep 17 00:00:00 2001 From: DanB Date: Thu, 17 Oct 2024 16:15:39 +0200 Subject: [PATCH] Protect Trend.asTrendSummary method --- engine/libtrends.go | 2 +- engine/trends.go | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/engine/libtrends.go b/engine/libtrends.go index ecb98cddf..e7398b13c 100644 --- a/engine/libtrends.go +++ b/engine/libtrends.go @@ -123,7 +123,7 @@ func (t *Trend) Clone() (tC *Trend) { } // AsTrendSummary transforms the trend into TrendSummary -func (t *Trend) AsTrendSummary() (ts *TrendSummary) { +func (t *Trend) asTrendSummary() (ts *TrendSummary) { ts = &TrendSummary{ Tenant: t.Tenant, ID: t.ID, diff --git a/engine/trends.go b/engine/trends.go index 92de9c51b..3b0e480ff 100644 --- a/engine/trends.go +++ b/engine/trends.go @@ -180,7 +180,9 @@ func (tS *TrendS) processThresholds(trnd *Trend) (err error) { copy(thIDs, trnd.tPrfl.ThresholdIDs) } opts[utils.OptsThresholdsProfileIDs] = thIDs - ts := trnd.AsTrendSummary() + trnd.tMux.RLock() + ts := trnd.asTrendSummary() + trnd.tMux.RUnlock() trndEv := &utils.CGREvent{ Tenant: trnd.Tenant, ID: utils.GenUUID(), @@ -218,7 +220,9 @@ func (tS *TrendS) processEEs(trnd *Trend) (err error) { opts := map[string]any{ utils.MetaEventType: utils.TrendUpdate, } - ts := trnd.AsTrendSummary() + trnd.tMux.RLock() + ts := trnd.asTrendSummary() + trnd.tMux.RUnlock() trndEv := &CGREventWithEeIDs{ CGREvent: &utils.CGREvent{ Tenant: trnd.Tenant,