Merge pull request #88 from tonistiigi/errretry-fix

flightcontrol: better errRetry handling
docker-18.09
Akihiro Suda 2017-07-26 15:06:58 +09:00 committed by GitHub
commit 08f8f24708
1 changed files with 7 additions and 6 deletions

View File

@ -27,6 +27,12 @@ type Group struct {
}
func (g *Group) Do(ctx context.Context, key string, fn func(ctx context.Context) (interface{}, error)) (v interface{}, err error) {
defer func() {
if errors.Cause(err) == errRetry {
runtime.Gosched()
v, err = g.Do(ctx, key, fn)
}
}()
g.mu.Lock()
if g.m == nil {
g.m = make(map[string]*call)
@ -34,12 +40,7 @@ func (g *Group) Do(ctx context.Context, key string, fn func(ctx context.Context)
if c, ok := g.m[key]; ok { // register 2nd waiter
g.mu.Unlock()
v, err := c.wait(ctx)
if err == errRetry {
runtime.Gosched()
return g.Do(ctx, key, fn)
}
return v, err
return c.wait(ctx)
}
c := newCall(fn)