Skip to content

Commit

Permalink
fix deadlocks
Browse files Browse the repository at this point in the history
  • Loading branch information
aarongable committed Sep 19, 2023
1 parent bf9f8f6 commit 7f432d2
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions crl/updater/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,21 @@ func (cu *crlUpdater) RunOnce(ctx context.Context) error {
shardWorker := func(in <-chan workItem) {
defer wg.Done()

for work := range in {
err := cu.updateShardWithRetry(ctx, atTime, work.issuerNameID, work.shardIdx, nil)
if err != nil {
cu.log.AuditErrf(
"Generating CRL failed: id=[%s] err=[%s]",
crl.Id(work.issuerNameID, work.shardIdx, crl.Number(atTime)), err)
once.Do(func() { anyErr = true })
}

for {
select {
case <-ctx.Done():
return
default:
continue
case work, ok := <-in:
if !ok {
return
}
err := cu.updateShardWithRetry(ctx, atTime, work.issuerNameID, work.shardIdx, nil)
if err != nil {
cu.log.AuditErrf(
"Generating CRL failed: id=[%s] err=[%s]",
crl.Id(work.issuerNameID, work.shardIdx, crl.Number(atTime)), err)
once.Do(func() { anyErr = true })
}
}
}
}
Expand All @@ -59,8 +60,7 @@ func (cu *crlUpdater) RunOnce(ctx context.Context) error {
close(inputs)
wg.Wait()
return ctx.Err()
default:
inputs <- workItem{issuerNameID: issuer.NameID(), shardIdx: i}
case inputs <- workItem{issuerNameID: issuer.NameID(), shardIdx: i}:
}
}
}
Expand Down

0 comments on commit 7f432d2

Please sign in to comment.