use better demo locking to prevent double parsing

This commit is contained in:
2022-08-20 16:03:39 +02:00
parent 657ca32bb3
commit 25965cdde7

View File

@@ -240,10 +240,17 @@ func (dml *DemoMatchLoader) Setup(config *DemoMatchLoaderConfig) error {
}
func (dml *DemoMatchLoader) LoadDemo(demo *Demo) error {
if dml.IsLoading(demo) {
log.Infof("[DL] Skipping %s: parsing in progress", demo.ShareCode)
return nil
}
dml.lockDemo(demo)
select {
case dml.parseDemo <- demo:
return nil
default:
dml.unlockDemo(demo)
return fmt.Errorf("queue full")
}
}
@@ -368,11 +375,6 @@ func (dml *DemoMatchLoader) demoWorker() {
}
func (dml *DemoMatchLoader) handleDemo(demo *Demo, apiKey string, rl *rate.Limiter) error {
if dml.IsLoading(demo) {
log.Infof("[DL] Skipping %s: parsing in progress", demo.ShareCode)
return nil
}
dml.lockDemo(demo)
defer dml.unlockDemo(demo)
if !dml.GCReady {