diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-04-13 02:42:56 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-04-13 08:19:01 -0600 |
commit | f4d10a92abc46bf0156ff1b475304471c16405da (patch) | |
tree | 1c7dd77840d8b0851b58d4a1faf90ccd0da1805a /cmd/btrfs-rec/inspect/rebuildtrees/scan.go | |
parent | b35aa24d868637332c1ba804a12911445a5a664b (diff) |
Try to find misuses of textui.Progress
- Add a runtime-check to Progress to notice if we deadlocked or
forgot to call .Done().
- Add a runtime-check to Progress.Done() to panic if .Set() was never
called (instead of the old behavior of deadlocking).
- grep: Use `defer` when possible, to help remember to call .Done().
- grep: Always either call .Set() right away, or right before calling
.Done().
Diffstat (limited to 'cmd/btrfs-rec/inspect/rebuildtrees/scan.go')
-rw-r--r-- | cmd/btrfs-rec/inspect/rebuildtrees/scan.go | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/cmd/btrfs-rec/inspect/rebuildtrees/scan.go b/cmd/btrfs-rec/inspect/rebuildtrees/scan.go index f266dab..b1469ff 100644 --- a/cmd/btrfs-rec/inspect/rebuildtrees/scan.go +++ b/cmd/btrfs-rec/inspect/rebuildtrees/scan.go @@ -73,6 +73,7 @@ func ScanDevices(_ctx context.Context, fs *btrfs.FS, nodeList []btrfsvol.Logical progressWriter.Set(stats) for _, laddr := range nodeList { if err := ctx.Err(); err != nil { + progressWriter.Done() return ScanDevicesResult{}, err } node, err := fs.AcquireNode(ctx, laddr, btrfstree.NodeExpectations{ @@ -80,6 +81,7 @@ func ScanDevices(_ctx context.Context, fs *btrfs.FS, nodeList []btrfsvol.Logical }) if err != nil { fs.ReleaseNode(node) + progressWriter.Done() return ScanDevicesResult{}, err } ret.insertNode(node) |