mirror of
https://github.com/SSLMate/certspotter.git
synced 2025-06-27 10:15:33 +02:00
Simplify context cancellation checks
This commit is contained in:
parent
56af38ca70
commit
90ead642b0
@ -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 {
|
||||||
|
@ -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():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user