mounttablelib: Add a runtime.Gosched() in the glob main loop to give others
a chance when the system is slow.
Change-Id: I1f1a23977a1de1f1710a119abb8d7c0df8fe62d8
diff --git a/services/mounttable/mounttablelib/mounttable.go b/services/mounttable/mounttablelib/mounttable.go
index 358c57f..b97014a 100644
--- a/services/mounttable/mounttablelib/mounttable.go
+++ b/services/mounttable/mounttablelib/mounttable.go
@@ -8,6 +8,7 @@
import (
"os"
"reflect"
+ "runtime"
"strings"
"sync"
"time"
@@ -650,6 +651,9 @@
func (mt *mountTable) globStep(ctx *context.T, call security.Call, n *node, name string, pattern *glob.Glob, ch chan<- naming.GlobReply) {
ctx.VI(2).Infof("globStep(%s, %s)", name, pattern)
+ // Globing is the lowest priority so we give up the cpu often.
+ runtime.Gosched()
+
// If this is a mount point, we're done.
if m := n.mount; m != nil {
removed := n.removeUseless(mt)