[#1047] policer: Check context before job selection

When application is being terminated, replicator routine
might be on the object picking phase. Storage is terminated
asynchronously, thus `Select()` may return corresponding
error. If we don't process `context.Done()` in this case,
then application freezes on shutdown.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2021-12-20 11:36:24 +03:00 committed by Alex Vanin
parent 11466ea3cc
commit bca7cf9470

View file

@ -27,6 +27,12 @@ func (p *Policer) shardPolicyWorker(ctx context.Context) {
)
for {
select {
case <-ctx.Done():
return
default:
}
addrs, cursor, err = p.jobQueue.Select(cursor, p.batchSize)
if err != nil {
if errors.Is(err, engine.ErrEndOfListing) {