revert player-based locks
This commit is contained in:
@@ -56,8 +56,6 @@ type DemoMatchLoader struct {
|
|||||||
parseDemo chan *Demo
|
parseDemo chan *Demo
|
||||||
parseMap map[string]bool
|
parseMap map[string]bool
|
||||||
parseMapL *sync.RWMutex
|
parseMapL *sync.RWMutex
|
||||||
parsePlayerMap map[uint32]*sync.RWMutex
|
|
||||||
parsePlayerMapL *sync.RWMutex
|
|
||||||
cache *cache.Cache
|
cache *cache.Cache
|
||||||
connectionWait uint64
|
connectionWait uint64
|
||||||
connectFeedback chan int
|
connectFeedback chan int
|
||||||
@@ -191,8 +189,6 @@ func (dml *DemoMatchLoader) Setup(config *DemoMatchLoaderConfig) error {
|
|||||||
dml.dp = &DemoParser{}
|
dml.dp = &DemoParser{}
|
||||||
dml.parseMap = map[string]bool{}
|
dml.parseMap = map[string]bool{}
|
||||||
dml.parseMapL = new(sync.RWMutex)
|
dml.parseMapL = new(sync.RWMutex)
|
||||||
dml.parsePlayerMap = map[uint32]*sync.RWMutex{}
|
|
||||||
dml.parsePlayerMapL = new(sync.RWMutex)
|
|
||||||
dml.cache = config.Cache
|
dml.cache = config.Cache
|
||||||
dml.retryTimeout = config.RetryTimeout
|
dml.retryTimeout = config.RetryTimeout
|
||||||
dml.connectFeedback = make(chan int, 10)
|
dml.connectFeedback = make(chan int, 10)
|
||||||
@@ -426,33 +422,13 @@ func (dml *DemoMatchLoader) handleDemo(demo *Demo, apiKey string, rl *rate.Limit
|
|||||||
lastRound := matchZero.GetRoundstatsall()[len(matchZero.Roundstatsall)-1]
|
lastRound := matchZero.GetRoundstatsall()[len(matchZero.Roundstatsall)-1]
|
||||||
var players []*ent.Player
|
var players []*ent.Player
|
||||||
|
|
||||||
dml.parsePlayerMapL.Lock()
|
|
||||||
for _, accID := range lastRound.GetReservation().GetAccountIds() {
|
|
||||||
if dml.parsePlayerMap[accID] == nil {
|
|
||||||
dml.parsePlayerMap[accID] = new(sync.RWMutex)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dml.parsePlayerMapL.Unlock()
|
|
||||||
|
|
||||||
dml.parsePlayerMapL.RLock()
|
|
||||||
for _, accountId := range lastRound.GetReservation().GetAccountIds() {
|
for _, accountId := range lastRound.GetReservation().GetAccountIds() {
|
||||||
dml.parsePlayerMap[accountId].Lock()
|
|
||||||
tPlayer, err := utils.Player(dml.db, AccountId2SteamId(accountId), apiKey, rl)
|
tPlayer, err := utils.Player(dml.db, AccountId2SteamId(accountId), apiKey, rl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
dml.parsePlayerMap[accountId].Unlock()
|
|
||||||
dml.parsePlayerMapL.RUnlock()
|
|
||||||
return fmt.Errorf("error getting player for steamid %d: %w", AccountId2SteamId(accountId), err)
|
return fmt.Errorf("error getting player for steamid %d: %w", AccountId2SteamId(accountId), err)
|
||||||
}
|
}
|
||||||
players = append(players, tPlayer)
|
players = append(players, tPlayer)
|
||||||
}
|
}
|
||||||
dml.parsePlayerMapL.RUnlock()
|
|
||||||
defer func() {
|
|
||||||
dml.parsePlayerMapL.RLock()
|
|
||||||
for _, accountId := range lastRound.GetReservation().GetAccountIds() {
|
|
||||||
dml.parsePlayerMap[accountId].Unlock()
|
|
||||||
}
|
|
||||||
dml.parsePlayerMapL.RUnlock()
|
|
||||||
}()
|
|
||||||
|
|
||||||
demo.Url = lastRound.GetMap()
|
demo.Url = lastRound.GetMap()
|
||||||
demo.MatchId = matchZero.GetMatchid()
|
demo.MatchId = matchZero.GetMatchid()
|
||||||
|
Reference in New Issue
Block a user