diff --git a/csgo/demo_loader.go b/csgo/demo_loader.go index 044dfb4..a0dfc2c 100644 --- a/csgo/demo_loader.go +++ b/csgo/demo_loader.go @@ -56,8 +56,6 @@ type DemoMatchLoader struct { parseDemo chan *Demo parseMap map[string]bool parseMapL *sync.RWMutex - parsePlayerMap map[uint32]*sync.RWMutex - parsePlayerMapL *sync.RWMutex cache *cache.Cache connectionWait uint64 connectFeedback chan int @@ -191,8 +189,6 @@ func (dml *DemoMatchLoader) Setup(config *DemoMatchLoaderConfig) error { dml.dp = &DemoParser{} dml.parseMap = map[string]bool{} dml.parseMapL = new(sync.RWMutex) - dml.parsePlayerMap = map[uint32]*sync.RWMutex{} - dml.parsePlayerMapL = new(sync.RWMutex) dml.cache = config.Cache dml.retryTimeout = config.RetryTimeout 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] 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() { - dml.parsePlayerMap[accountId].Lock() tPlayer, err := utils.Player(dml.db, AccountId2SteamId(accountId), apiKey, rl) if err != nil { - dml.parsePlayerMap[accountId].Unlock() - dml.parsePlayerMapL.RUnlock() return fmt.Errorf("error getting player for steamid %d: %w", AccountId2SteamId(accountId), err) } 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.MatchId = matchZero.GetMatchid()