1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-07-02 03:28:25 +08:00

Merge pull request #776 from jbenet/fix/mdag-panic

fix a panic caused by context cancelling closing a promise channel
This commit is contained in:
Juan Batiz-Benet
2015-02-12 18:34:58 -08:00

View File

@ -151,7 +151,15 @@ func (bs *bitswap) GetBlock(parent context.Context, k u.Key) (*blocks.Block, err
}
select {
case block := <-promise:
case block, ok := <-promise:
if !ok {
select {
case <-ctx.Done():
return nil, ctx.Err()
default:
return nil, errors.New("promise channel was closed")
}
}
return block, nil
case <-parent.Done():
return nil, parent.Err()