fixed locking
This commit is contained in:
@@ -315,7 +315,9 @@ func (d *DemoMatchLoader) gcWorker(apiKey string, rl ratelimit.Limiter) {
|
|||||||
if !d.GCReady {
|
if !d.GCReady {
|
||||||
log.Infof("[DL] Postponing match %d (%s): GC not ready", demo.MatchId, demo.ShareCode)
|
log.Infof("[DL] Postponing match %d (%s): GC not ready", demo.MatchId, demo.ShareCode)
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
|
d.parseMapL.Lock()
|
||||||
delete(d.parseMap, demo.ShareCode)
|
delete(d.parseMap, demo.ShareCode)
|
||||||
|
d.parseMapL.Unlock()
|
||||||
d.parseDemo <- demo
|
d.parseDemo <- demo
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -323,7 +325,9 @@ func (d *DemoMatchLoader) gcWorker(apiKey string, rl ratelimit.Limiter) {
|
|||||||
matchId, _, _, err := DecodeSharecode(demo.ShareCode)
|
matchId, _, _, err := DecodeSharecode(demo.ShareCode)
|
||||||
if err != nil || matchId == 0 {
|
if err != nil || matchId == 0 {
|
||||||
log.Warningf("[DL] Can't parse match with sharecode %s: %v", demo.ShareCode, err)
|
log.Warningf("[DL] Can't parse match with sharecode %s: %v", demo.ShareCode, err)
|
||||||
|
d.parseMapL.Lock()
|
||||||
delete(d.parseMap, demo.ShareCode)
|
delete(d.parseMap, demo.ShareCode)
|
||||||
|
d.parseMapL.Unlock()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -334,7 +338,9 @@ func (d *DemoMatchLoader) gcWorker(apiKey string, rl ratelimit.Limiter) {
|
|||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
log.Errorf("[DL] Failure trying to lookup match %d in db: %v", matchId, e)
|
log.Errorf("[DL] Failure trying to lookup match %d in db: %v", matchId, e)
|
||||||
|
d.parseMapL.Lock()
|
||||||
delete(d.parseMap, demo.ShareCode)
|
delete(d.parseMap, demo.ShareCode)
|
||||||
|
d.parseMapL.Unlock()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -346,19 +352,25 @@ func (d *DemoMatchLoader) gcWorker(apiKey string, rl ratelimit.Limiter) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warningf("[DL] Parsing demo from match %d failed: %v", demo.MatchId, err)
|
log.Warningf("[DL] Parsing demo from match %d failed: %v", demo.MatchId, err)
|
||||||
}
|
}
|
||||||
|
d.parseMapL.Lock()
|
||||||
delete(d.parseMap, demo.ShareCode)
|
delete(d.parseMap, demo.ShareCode)
|
||||||
|
d.parseMapL.Unlock()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debugf("[DL] Skipped match %d: already parsed", matchId)
|
log.Debugf("[DL] Skipped match %d: already parsed", matchId)
|
||||||
|
d.parseMapL.Lock()
|
||||||
delete(d.parseMap, demo.ShareCode)
|
delete(d.parseMap, demo.ShareCode)
|
||||||
|
d.parseMapL.Unlock()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
matchDetails, err := d.getMatchDetails(demo.ShareCode)
|
matchDetails, err := d.getMatchDetails(demo.ShareCode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warningf("[DL] Failure to get match-details for %d from GC: %v", demo.MatchId, err)
|
log.Warningf("[DL] Failure to get match-details for %d from GC: %v", demo.MatchId, err)
|
||||||
|
d.parseMapL.Lock()
|
||||||
delete(d.parseMap, demo.ShareCode)
|
delete(d.parseMap, demo.ShareCode)
|
||||||
|
d.parseMapL.Unlock()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -392,7 +404,9 @@ func (d *DemoMatchLoader) gcWorker(apiKey string, rl ratelimit.Limiter) {
|
|||||||
Save(context.Background())
|
Save(context.Background())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warningf("[DL] Unable to create match %d: %v", matchZero.GetMatchid(), err)
|
log.Warningf("[DL] Unable to create match %d: %v", matchZero.GetMatchid(), err)
|
||||||
|
d.parseMapL.Lock()
|
||||||
delete(d.parseMap, demo.ShareCode)
|
delete(d.parseMap, demo.ShareCode)
|
||||||
|
d.parseMapL.Unlock()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -473,6 +487,8 @@ func (d *DemoMatchLoader) gcWorker(apiKey string, rl ratelimit.Limiter) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warningf("[DL] Can't queue demo %d for parsing: %v", demo.MatchId, err)
|
log.Warningf("[DL] Can't queue demo %d for parsing: %v", demo.MatchId, err)
|
||||||
}
|
}
|
||||||
|
d.parseMapL.Lock()
|
||||||
delete(d.parseMap, demo.ShareCode)
|
delete(d.parseMap, demo.ShareCode)
|
||||||
|
d.parseMapL.Unlock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user