Add stage locks on find session function

This commit is contained in:
Sophie
2020-03-10 08:30:07 +00:00
parent 4c27b99e9a
commit 081deba17b

View File

@@ -169,12 +169,16 @@ func (s *Server) BroadcastMHF(pkt mhfpacket.MHFPacket, ignoredSession *Session)
}
func (s *Server) FindSessionByCharID(charID uint32) *Session {
s.stagesLock.RLock()
defer s.stagesLock.RUnlock()
for _, stage := range s.stages {
stage.RLock()
for client := range stage.clients {
if client.charID == charID {
return client
}
}
stage.RUnlock()
}
return nil