mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-21 23:22:34 +01:00
test(channelserver): add store tests and document lock ordering
Add unit tests with race-detector coverage for QuestCache, UserBinaryStore, and MinidataStore (18 tests covering hits, misses, expiry, copy isolation, and concurrent access). Document the lock acquisition order on the Server struct to prevent future deadlocks: Server.Mutex → stagesLock → Stage → semaphoreLock.
This commit is contained in:
@@ -30,6 +30,15 @@ type Config struct {
|
||||
}
|
||||
|
||||
// Server is a MHF channel server.
|
||||
//
|
||||
// Lock ordering (acquire in this order to avoid deadlocks):
|
||||
// 1. Server.Mutex – protects sessions map
|
||||
// 2. Server.stagesLock – protects stages map
|
||||
// 3. Stage.RWMutex – protects per-stage state (clients, objects)
|
||||
// 4. Server.semaphoreLock – protects semaphore map
|
||||
//
|
||||
// Self-contained stores (userBinary, minidata, questCache) manage their
|
||||
// own locks internally and may be acquired at any point.
|
||||
type Server struct {
|
||||
sync.Mutex
|
||||
Channels []*Server
|
||||
|
||||
Reference in New Issue
Block a user