From 61acc7494abe1f223da3f427ba5dc3c62d52ecbc Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Sun, 24 Jan 2021 13:57:20 +0100 Subject: [PATCH] [#388] endpoint: fix incorrect use of trace.WithTaskGroup in ListAbstractionsStreamed Capturing behavior was broken. --- client/zfsabstractions_list.go | 2 +- endpoint/endpoint_zfs_abstraction.go | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/client/zfsabstractions_list.go b/client/zfsabstractions_list.go index 0b86d7f..2f7a151 100644 --- a/client/zfsabstractions_list.go +++ b/client/zfsabstractions_list.go @@ -52,9 +52,9 @@ func doZabsList(ctx context.Context, sc *cli.Subcommand, args []string) error { var line chainlock.L var wg sync.WaitGroup defer wg.Wait() - wg.Add(1) // print results + wg.Add(1) go func() { defer wg.Done() enc := json.NewEncoder(os.Stdout) diff --git a/endpoint/endpoint_zfs_abstraction.go b/endpoint/endpoint_zfs_abstraction.go index 616803b..c01f070 100644 --- a/endpoint/endpoint_zfs_abstraction.go +++ b/endpoint/endpoint_zfs_abstraction.go @@ -579,16 +579,17 @@ func ListAbstractionsStreamed(ctx context.Context, query ListZFSHoldsAndBookmark _, add, wait := trace.WithTaskGroup(ctx, "list-abstractions-impl-fs") defer wait() - for i := range fss { + for _, fs := range fss { + fs := fs // capture by copy add(func(ctx context.Context) { g, err := sem.Acquire(ctx) if err != nil { - errCb(err, fss[i], err.Error()) + errCb(err, fs, err.Error()) return } func() { defer g.Release() - listAbstractionsImplFS(ctx, fss[i], &query, emitAbstraction, errCb) + listAbstractionsImplFS(ctx, fs, &query, emitAbstraction, errCb) }() }) }