refactor(channelserver): extract UserBinaryStore and MinidataStore

The userBinary and minidata maps with their locks were spread across
Server as raw fields with manual lock management. Cross-channel session
searches also required acquiring nested locks (server lock + binary
lock). Encapsulating in dedicated types eliminates the nested locking
and reduces Server's field count by 4.
This commit is contained in:
Houmgaor
2026-02-21 13:39:44 +01:00
parent 2757a5432f
commit c04fa504cc
15 changed files with 111 additions and 68 deletions

View File

@@ -536,7 +536,6 @@ func handleMsgMhfTransitMessage(s *Session, p mhfpacket.MHFPacket) {
break
}
c.Lock()
c.userBinaryPartsLock.RLock()
for _, session := range c.sessions {
if count == maxResults {
break
@@ -551,19 +550,15 @@ func handleMsgMhfTransitMessage(s *Session, p mhfpacket.MHFPacket) {
continue
}
count++
ub3 := c.userBinaryParts[userBinaryPartID{charID: session.charID, index: 3}]
ub3Copy := make([]byte, len(ub3))
copy(ub3Copy, ub3)
results = append(results, sessionResult{
charID: session.charID,
name: stringsupport.UTF8ToSJIS(session.Name),
stageID: stringsupport.UTF8ToSJIS(session.stage.id),
ip: net.ParseIP(c.IP).To4(),
port: c.Port,
userBin3: ub3Copy,
userBin3: c.userBinary.GetCopy(session.charID, 3),
})
}
c.userBinaryPartsLock.RUnlock()
c.Unlock()
}