Simplify context cancellation checks

This commit is contained in:
Andrew Ayer 2025-05-21 14:31:24 -04:00
parent 56af38ca70
commit 90ead642b0
2 changed files with 2 additions and 17 deletions

View File

@ -137,9 +137,10 @@ func (daemon *daemon) run(ctx context.Context) error {
healthCheckTicker := time.NewTicker(daemon.config.HealthCheckInterval) healthCheckTicker := time.NewTicker(daemon.config.HealthCheckInterval)
defer healthCheckTicker.Stop() defer healthCheckTicker.Stop()
for ctx.Err() == nil { for {
select { select {
case <-ctx.Done(): case <-ctx.Done():
return ctx.Err()
case <-reloadLogListTicker.C: case <-reloadLogListTicker.C:
if err := daemon.loadLogList(ctx); err != nil { if err := daemon.loadLogList(ctx); err != nil {
daemon.logListError = err.Error() daemon.logListError = err.Error()
@ -153,7 +154,6 @@ func (daemon *daemon) run(ctx context.Context) error {
} }
} }
} }
return ctx.Err()
} }
func Run(ctx context.Context, config *Config) error { func Run(ctx context.Context, config *Config) error {

View File

@ -444,11 +444,6 @@ func generateBatchesWorker(ctx context.Context, config *Config, ctlog *loglist.L
func downloadWorker(ctx context.Context, config *Config, ctlog *loglist.Log, client ctclient.Log, batchesIn <-chan *batch, batchesOut chan<- *batch) error { func downloadWorker(ctx context.Context, config *Config, ctlog *loglist.Log, client ctclient.Log, batchesIn <-chan *batch, batchesOut chan<- *batch) error {
for { for {
select {
case <-ctx.Done():
return ctx.Err()
default:
}
var batch *batch var batch *batch
select { select {
case <-ctx.Done(): case <-ctx.Done():
@ -462,11 +457,6 @@ func downloadWorker(ctx context.Context, config *Config, ctlog *loglist.Log, cli
} }
batch.entries = entries batch.entries = entries
select {
case <-ctx.Done():
return ctx.Err()
default:
}
select { select {
case <-ctx.Done(): case <-ctx.Done():
return ctx.Err() return ctx.Err()
@ -477,11 +467,6 @@ func downloadWorker(ctx context.Context, config *Config, ctlog *loglist.Log, cli
func processWorker(ctx context.Context, config *Config, ctlog *loglist.Log, issuerGetter ctclient.IssuerGetter, batchesIn <-chan *batch, batchesOut *sequencer.Channel[batch]) error { func processWorker(ctx context.Context, config *Config, ctlog *loglist.Log, issuerGetter ctclient.IssuerGetter, batchesIn <-chan *batch, batchesOut *sequencer.Channel[batch]) error {
for { for {
select {
case <-ctx.Done():
return ctx.Err()
default:
}
var batch *batch var batch *batch
select { select {
case <-ctx.Done(): case <-ctx.Done():