@cryptotaxi247 / kubo / commits / 725eefaeb

fix(commands): fix filestore.go goroutine leak

License: MIT Signed-off-by: Overbool <overbool.xu@gmail.com>

Overbool committed Sep 7, 2018 at 23:12 UTC 725eefaeb0e8b34ac218b57cc30ea37137f763af
1 file changed +9 -2
core/commands/filestore.go
+9 -2
@@ -218,11 +218,18 @@ var dupsFileStore = &oldCmds.Command{
218 for cid := range ch {
219 have, err := fs.MainBlockstore().Has(cid)
220 if err != nil {
221 - out <- &RefWrapper{Err: err.Error()}
221 + select {
222 + case out <- &RefWrapper{Err: err.Error()}:
223 + case <-req.Context().Done():
224 + }
225 return
226 }
227 if have {
225 - out <- &RefWrapper{Ref: cid.String()}
228 + select {
229 + case out <- &RefWrapper{Ref: cid.String()}:
230 + case <-req.Context().Done():
231 + return
232 + }
233 }
234 }
235 }()