tpl: Fix deadlock in cached partials
authorCameron Moore <moorereason@gmail.com>
Tue, 17 Jan 2017 18:51:24 +0000 (12:51 -0600)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 18 Jan 2017 09:30:22 +0000 (10:30 +0100)
Cached partials that contained cached partials would create a deadlock.

Fixes #2935

tpl/template_funcs.go

index 6c8a9957ee422ff5cdcc5149292c55247ba075fc..8f653808b52bde82f0b4788be69bb23ca4260e0b 100644 (file)
@@ -1541,7 +1541,10 @@ func (tf *templateFuncster) Get(key, name string, context interface{}) (p templa
 
        tf.cachedPartials.Lock()
        if p, ok = tf.cachedPartials.p[key]; !ok {
+               tf.cachedPartials.Unlock()
                p = tf.t.partial(name, context)
+
+               tf.cachedPartials.Lock()
                tf.cachedPartials.p[key] = p
        }
        tf.cachedPartials.Unlock()