lib/model: Don't exit pullerRoutine on cancelled ctx (fixes #6559) (#6562)

* lib/model: Don't exit pullerRoutine on cancelled ctx (fixes #6559)

* actual fix
This commit is contained in:
Simon Frei
2020-04-21 18:55:14 +01:00
committed by GitHub
parent 6bbd24de12
commit d3ed4de4ed
4 changed files with 76 additions and 21 deletions
+6
View File
@@ -51,6 +51,12 @@ func (s *byteSemaphore) take(bytes int) {
}
func (s *byteSemaphore) takeInner(ctx context.Context, bytes int) error {
// Checking context for bytes <= s.available is required for testing and doesn't do any harm.
select {
case <-ctx.Done():
return ctx.Err()
default:
}
s.mut.Lock()
defer s.mut.Unlock()
if bytes > s.max {