From c8ec4170f30985e97be0a60c7bc37f91f8181fda Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 10 Jan 2020 15:53:30 +0200 Subject: [PATCH] Added back the locks to AsExternalSessions --- sessions/session.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sessions/session.go b/sessions/session.go index 2a0e9b977..582f60b25 100644 --- a/sessions/session.go +++ b/sessions/session.go @@ -130,8 +130,9 @@ func (s *Session) Clone() (cln *Session) { return } -// AsExternalSessions returns the session as a list of ExternalSession using all SRuns +// AsExternalSessions returns the session as a list of ExternalSession using all SRuns (thread safe) func (s *Session) AsExternalSessions(tmz, nodeID string) (aSs []*ExternalSession) { + s.RLock() aSs = make([]*ExternalSession, len(s.SRuns)) for i, sr := range s.SRuns { aSs[i] = &ExternalSession{ @@ -165,6 +166,7 @@ func (s *Session) AsExternalSessions(tmz, nodeID string) (aSs []*ExternalSession aSs[i].MaxCostSoFar = sr.CD.MaxCostSoFar } } + s.RUnlock() return }