fix goroutine leaks in filestore.go
License: MIT Signed-off-by: Kejie Zhang <601172892@qq.com>
Kejie Zhang committed
Sep 5, 2018 at 20:57 UTC
7a9c7b4dd35124a5e8ef092184af3e78ccadebfc
1 file changed
+5
-1
core/commands/filestore.go
+5
-1
@@ -269,10 +269,14 @@ func perKeyActionToChan(ctx context.Context, args []string, action func(*cid.Cid
269
for _, arg := range args {
270
c, err := cid.Decode(arg)
271
if err != nil {
272
- out <- &filestore.ListRes{
272
+ select {
273
+ case out <- &filestore.ListRes{
274
Status: filestore.StatusOtherError,
275
ErrorMsg: fmt.Sprintf("%s: %v", arg, err),
276
+ }:
277
+ case <-ctx.Done():
278
}
279
+
280
continue
281
}
282
r := action(c)