From 6097c4c634b8644e4ac1e0520f39a6bc501d227d Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 7 Jan 2023 14:03:47 -0700 Subject: rebuildnodes: Don't deadlock if the cpu goroutine panics --- lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/btrfsprogs/btrfsinspect') diff --git a/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go b/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go index 9f7ce9f..bc4d7c9 100644 --- a/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go +++ b/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go @@ -264,10 +264,14 @@ func (o *rebuilder) processSettledItemQueue(ctx context.Context) error { return err } ctx := dlog.WithField(ctx, "btrfsinspect.rebuild-nodes.rebuild.process.item", key) - itemChan <- keyAndBody{ + item := keyAndBody{ keyAndTree: key, Body: o.rebuilt.Tree(ctx, key.TreeID).ReadItem(ctx, key.Key), } + select { + case itemChan <- item: + case <-ctx.Done(): + } } return nil }) -- cgit v1.2.3-54-g00ecf