From 3ee6355cd25948e1a98bf3e47858266a24ca8060 Mon Sep 17 00:00:00 2001 From: ionutboangiu Date: Mon, 1 Sep 2025 21:21:56 +0300 Subject: [PATCH] sessions: remove UpdateSRuns and lock manually in terminate --- sessions/apis.go | 4 +++- sessions/session.go | 12 ------------ 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/sessions/apis.go b/sessions/apis.go index 5acf8adf3..d5c642a27 100644 --- a/sessions/apis.go +++ b/sessions/apis.go @@ -672,7 +672,9 @@ func (sS *SessionS) BiRPCv1TerminateSession(ctx *context.Context, break } if !isInstantEvent { - s.UpdateSRuns(ev, sS.cfg.SessionSCfg().AlterableFields) + s.lk.Lock() + s.updateSRuns(ev, sS.cfg.SessionSCfg().AlterableFields) + s.lk.Unlock() } if err = sS.terminateSession(ctx, s, ev.GetDurationPtrIgnoreErrors(utils.Usage), diff --git a/sessions/session.go b/sessions/session.go index 8dee43a0c..63a4abc2a 100644 --- a/sessions/session.go +++ b/sessions/session.go @@ -220,15 +220,3 @@ func (s *Session) updateSRuns(updEv engine.MapEvent, alterableFields utils.Strin } } } - -// UpdateSRuns updates the SRuns event with the alterable fields (is thread safe) -func (s *Session) UpdateSRuns(updEv engine.MapEvent, alterableFields utils.StringSet) { - if alterableFields.Size() == 0 { // do not lock if we can't update any field - return - } - - // TODO: fix deadlock when called by updateSession method. - s.lk.Lock() - s.updateSRuns(updEv, alterableFields) - s.lk.Unlock() -}