fix issue where broadcasts can go to unmapped sessions

This commit is contained in:
wish
2022-11-12 02:50:32 +11:00
parent c718e9a5a7
commit 6897a03781
2 changed files with 2 additions and 2 deletions

View File

@@ -135,7 +135,6 @@ func destructEmptyStages(s *Session) {
func removeSessionFromStage(s *Session) { func removeSessionFromStage(s *Session) {
// Remove client from old stage. // Remove client from old stage.
s.stage.Lock()
delete(s.stage.clients, s) delete(s.stage.clients, s)
// Delete old stage objects owned by the client. // Delete old stage objects owned by the client.
@@ -146,7 +145,6 @@ func removeSessionFromStage(s *Session) {
delete(s.stage.objects, object.ownerCharID) delete(s.stage.objects, object.ownerCharID)
} }
} }
s.stage.Unlock()
destructEmptyStages(s) destructEmptyStages(s)
destructEmptySemaphores(s) destructEmptySemaphores(s)
} }

View File

@@ -69,6 +69,8 @@ func NewStage(ID string) *Stage {
// BroadcastMHF queues a MHFPacket to be sent to all sessions in the stage. // BroadcastMHF queues a MHFPacket to be sent to all sessions in the stage.
func (s *Stage) BroadcastMHF(pkt mhfpacket.MHFPacket, ignoredSession *Session) { func (s *Stage) BroadcastMHF(pkt mhfpacket.MHFPacket, ignoredSession *Session) {
s.Lock()
defer s.Unlock()
// Broadcast the data. // Broadcast the data.
for session := range s.clients { for session := range s.clients {
if session == ignoredSession { if session == ignoredSession {