Added back the locks to AsExternalSessions

This commit is contained in:
Trial97
2020-01-10 15:53:30 +02:00
parent 3d294dc4cd
commit c8ec4170f3

View File

@@ -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
}