prevent concurrent map write to questCache

This commit is contained in:
wish
2025-03-08 11:41:57 +11:00
parent 3e71c308f4
commit f2862ea4b8
2 changed files with 3 additions and 0 deletions

View File

@@ -238,8 +238,10 @@ func loadQuestFile(s *Session, questId int) []byte {
} }
questBody.WriteBytes(newStrings.Data()) questBody.WriteBytes(newStrings.Data())
s.server.questCacheLock.Lock()
s.server.questCacheData[questId] = questBody.Data() s.server.questCacheData[questId] = questBody.Data()
s.server.questCacheTime[questId] = time.Now() s.server.questCacheTime[questId] = time.Now()
s.server.questCacheLock.Unlock()
return questBody.Data() return questBody.Data()
} }

View File

@@ -75,6 +75,7 @@ type Server struct {
raviente *Raviente raviente *Raviente
questCacheLock sync.RWMutex
questCacheData map[int][]byte questCacheData map[int][]byte
questCacheTime map[int]time.Time questCacheTime map[int]time.Time
} }