mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-20 10:54:51 +01:00
Add stage locks on find session function
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user