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

@@ -76,7 +76,6 @@ func (r *LocalChannelRegistry) SearchSessions(predicate func(SessionSnapshot) bo
break
}
c.Lock()
c.userBinaryPartsLock.RLock()
for _, session := range c.sessions {
if len(results) >= max {
break
@@ -90,16 +89,11 @@ func (r *LocalChannelRegistry) SearchSessions(predicate func(SessionSnapshot) bo
if session.stage != nil {
snap.StageID = session.stage.id
}
ub3 := c.userBinaryParts[userBinaryPartID{charID: session.charID, index: 3}]
if len(ub3) > 0 {
snap.UserBinary3 = make([]byte, len(ub3))
copy(snap.UserBinary3, ub3)
}
snap.UserBinary3 = c.userBinary.GetCopy(session.charID, 3)
if predicate(snap) {
results = append(results, snap)
}
}
c.userBinaryPartsLock.RUnlock()
c.Unlock()
}
return results