mirror of
https://github.com/minio/minio.git
synced 2025-01-11 23:13:23 -05:00
honor canceled context and do not leak on mergeChannels (#15034)
mergeEntryChannels has the potential to perpetually wait on the results channel, context might be closed and we did not honor the caller context canceling.
This commit is contained in:
parent
20a753e2e5
commit
c3e1da8e04
@ -695,8 +695,12 @@ func mergeEntryChannels(ctx context.Context, in []chan metaCacheEntry, out chan<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if best.name > last {
|
if best.name > last {
|
||||||
out <- *best
|
select {
|
||||||
|
case <-ctxDone:
|
||||||
|
return ctx.Err()
|
||||||
|
case out <- *best:
|
||||||
last = best.name
|
last = best.name
|
||||||
|
}
|
||||||
} else if serverDebugLog {
|
} else if serverDebugLog {
|
||||||
console.Debugln("mergeEntryChannels: discarding duplicate", best.name, "<=", last)
|
console.Debugln("mergeEntryChannels: discarding duplicate", best.name, "<=", last)
|
||||||
}
|
}
|
||||||
|
@ -554,11 +554,11 @@ func (z *erasureServerPools) listMerged(ctx context.Context, o listPathOptions,
|
|||||||
for _, pool := range z.serverPools {
|
for _, pool := range z.serverPools {
|
||||||
for _, set := range pool.sets {
|
for _, set := range pool.sets {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
results := make(chan metaCacheEntry, 100)
|
innerResults := make(chan metaCacheEntry, 100)
|
||||||
inputs = append(inputs, results)
|
inputs = append(inputs, innerResults)
|
||||||
go func(i int, set *erasureObjects) {
|
go func(i int, set *erasureObjects) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
err := set.listPath(listCtx, o, results)
|
err := set.listPath(listCtx, o, innerResults)
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
defer mu.Unlock()
|
defer mu.Unlock()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@ -609,6 +609,7 @@ func (z *erasureServerPools) listMerged(ctx context.Context, o listPathOptions,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if contextCanceled(ctx) {
|
if contextCanceled(ctx) {
|
||||||
return ctx.Err()
|
return ctx.Err()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user