[#388] endpoint: fix incorrect use of trace.WithTaskGroup in ListAbstractionsStreamed

Capturing behavior was broken.
This commit is contained in:
Christian Schwarz 2021-01-24 13:57:20 +01:00
parent 96d5288667
commit 61acc7494a
2 changed files with 5 additions and 4 deletions

View File

@ -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)

View File

@ -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)
}()
})
}