Browse Source
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.
pull/15037/head
Harshavardhana
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
10 additions and
5 deletions
cmd/metacache-entries.go
cmd/metacache-server-pool.go
@ -695,8 +695,12 @@ func mergeEntryChannels(ctx context.Context, in []chan metaCacheEntry, out chan<
}
}
if best . name > last {
out <- * best
last = best . name
select {
case <- ctxDone :
return ctx . Err ( )
case out <- * best :
last = best . name
}
} else if serverDebugLog {
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 _ , set := range pool . sets {
wg . Add ( 1 )
results := make ( chan metaCacheEntry , 100 )
inputs = append ( inputs , results )
inne rR esults := make ( chan metaCacheEntry , 100 )
inputs = append ( inputs , inne rR esults)
go func ( i int , set * erasureObjects ) {
defer wg . Done ( )
err := set . listPath ( listCtx , o , results )
err := set . listPath ( listCtx , o , inne rR esults)
mu . Lock ( )
defer mu . Unlock ( )
if err == nil {
@ -609,6 +609,7 @@ func (z *erasureServerPools) listMerged(ctx context.Context, o listPathOptions,
if err != nil {
return err
}
if contextCanceled ( ctx ) {
return ctx . Err ( )
}