aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--cmd/mbf/cache.go28
-rw-r--r--pkg/pkg.go27
2 files changed, 39 insertions, 16 deletions
diff --git a/cmd/mbf/cache.go b/cmd/mbf/cache.go
index 166e1c45..156a6834 100644
--- a/cmd/mbf/cache.go
+++ b/cmd/mbf/cache.go
@@ -72,7 +72,7 @@ func (cache *cache) open() (err error) {
} else if base, err = check.NewAbs(cache.base); err != nil {
return
}
- var notify chan bool
+ var notify chan int
if cache.idle {
cache.attr.Flags |= pkg.CSchedIdle
@@ -88,7 +88,7 @@ func (cache *cache) open() (err error) {
}
if cache.color {
cache.attr.Flags |= pkg.CColourOutput
- notify = make(chan bool, 1<<12)
+ notify = make(chan int, 1<<12)
cache.attr.Notify = notify
}
@@ -141,22 +141,32 @@ func (cache *cache) open() (err error) {
prefix := hostname + ": mbf "
go func() {
- var n, nc uint64
- for enter := range notify {
- if enter {
- nc++
- } else {
+ var n, nf, nc uint64
+ for kind := range notify {
+ switch kind {
+ case pkg.NExit:
nc--
n++
+ break
+
+ case pkg.NEnter:
+ nc++
+ break
+
+ case pkg.NFault:
+ nc--
+ nf++
+ break
}
- if nc == 0 {
+ if nf == 0 && nc == 0 {
writeTitle(cache.msg, prefix[:len(prefix)-1])
continue
}
writeTitle(cache.msg, prefix+
"("+strconv.FormatUint(nc, 10)+
- " running, "+strconv.FormatUint(n, 10)+" complete)")
+ " running, "+strconv.FormatUint(n, 10)+" complete, "+
+ strconv.FormatUint(nf, 10)+" fault)")
}
}()
}
diff --git a/pkg/pkg.go b/pkg/pkg.go
index 3515f99f..07d467c7 100644
--- a/pkg/pkg.go
+++ b/pkg/pkg.go
@@ -1785,10 +1785,19 @@ func (e InputError) Unwrap() []error {
return errs
}
+const (
+ // NExit indicates a cure implementation being exited.
+ NExit = iota
+ // NEnter indicates a cure implementation being entered.
+ NEnter
+ // NFault is sent in place of [NExit] for a faulting implementation.
+ NFault
+)
+
// enterCure must be called before entering an [Artifact] implementation.
func (c *Cache) enterCure(a Artifact, curesExempt bool) error {
if c.attr.Notify != nil {
- c.attr.Notify <- true
+ c.attr.Notify <- NEnter
}
if a.IsExclusive() {
@@ -1812,9 +1821,13 @@ func (c *Cache) enterCure(a Artifact, curesExempt bool) error {
}
// exitCure must be called after exiting an [Artifact] implementation.
-func (c *Cache) exitCure(a Artifact, curesExempt bool) {
+func (c *Cache) exitCure(a Artifact, curesExempt, ok bool) {
if c.attr.Notify != nil {
- c.attr.Notify <- false
+ if ok {
+ c.attr.Notify <- NExit
+ } else {
+ c.attr.Notify <- NFault
+ }
}
if a.IsExclusive() {
@@ -2282,7 +2295,7 @@ func (c *Cache) cure(a Artifact, curesExempt, rebuild bool) (
err = closeErr
}
}
- c.exitCure(a, curesExempt)
+ c.exitCure(a, curesExempt, err == nil)
if err != nil {
if c.msg.IsVerbose() {
c.msg.Verbosef(
@@ -2333,7 +2346,7 @@ func (c *Cache) cure(a Artifact, curesExempt, rebuild bool) (
return
}
err = ca.Cure(&t)
- c.exitCure(a, curesExempt)
+ c.exitCure(a, curesExempt, err == nil)
if err != nil {
if c.msg.IsVerbose() {
c.msg.Verbosef(
@@ -2505,7 +2518,7 @@ func (c *Cache) cure(a Artifact, curesExempt, rebuild bool) (
return
}
err = ca.Cure(&f)
- c.exitCure(a, curesExempt)
+ c.exitCure(a, curesExempt, err == nil)
if !rebuild && err == nil {
err = f.linkSubstitute(ids, substitutes)
@@ -2749,7 +2762,7 @@ type CacheAttr struct {
// Preferred loadavg target, when applicable.
Load int
// Optional cure entry and exit notification.
- Notify chan<- bool
+ Notify chan<- int
// Omit the [lockedfile] lock.
skipLock bool