@cryptotaxi247 / kubo / commits / 40c5cca11

fix(bitswap) always cancel on return

Brian Tiger Chow committed Nov 5, 2014 at 07:07 UTC 40c5cca1173dd1efa346cc8d92c31a0a766ed537
1 file changed +2 -1
exchange/bitswap/bitswap.go
+2 -1
@@ -88,6 +88,8 @@ func (bs *bitswap) Block(parent context.Context, k u.Key) (*blocks.Block, error)
88 }()
89
90 ctx, cancelFunc := context.WithCancel(parent)
91 + defer cancelFunc()
92 +
93 bs.wantlist.Add(k)
94 promise := bs.notifications.Subscribe(ctx, k)
95
@@ -130,7 +132,6 @@ func (bs *bitswap) Block(parent context.Context, k u.Key) (*blocks.Block, error)
132
133 select {
134 case block := <-promise:
133 - cancelFunc()
135 bs.wantlist.Remove(k)
136 return &block, nil
137 case <-parent.Done():