files: rpcstore context listen

This commit is contained in:
Sergey Cherepanov 2022-12-26 18:59:33 +03:00
parent acf21c7d54
commit 6fb720e0ea
No known key found for this signature in database
GPG Key ID: 87F8EDE8FBDF637C

View File

@ -91,7 +91,11 @@ func (c *client) opLoop(ctx context.Context) {
} }
if err != nil { if err != nil {
t.err = err t.err = err
t.ready <- t select {
case t.ready <- t:
case <-t.ctx.Done():
case <-ctx.Done():
}
} }
} }
} }
@ -107,7 +111,13 @@ func (c *client) delete(ctx context.Context, t *task) (err error) {
}); err != nil { }); err != nil {
return rpcerr.Unwrap(err) return rpcerr.Unwrap(err)
} }
t.ready <- t select {
case t.ready <- t:
case <-t.ctx.Done():
return t.ctx.Err()
case <-ctx.Done():
return ctx.Err()
}
c.stat.UpdateLastUsage() c.stat.UpdateLastUsage()
return return
} }
@ -128,6 +138,8 @@ func (c *client) put(ctx context.Context, t *task) (err error) {
log.Debug("put cid", zap.String("cid", t.cid.String())) log.Debug("put cid", zap.String("cid", t.cid.String()))
select { select {
case t.ready <- t: case t.ready <- t:
case <-t.ctx.Done():
return t.ctx.Err()
case <-ctx.Done(): case <-ctx.Done():
return ctx.Err() return ctx.Err()
} }