diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2015-11-21 21:57:26 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2015-11-21 21:57:26 +0100 |
commit | c5f40e8b8ba1d8eaac11bbbf3b537e3e4e94c860 (patch) | |
tree | 440ee7321fe6861ccfb146dd4b8f8dba2f4b2f75 /hugolib/shortcode.go | |
parent | 58c446f56282cb8c24f5dce0ef03e5e7bebe00ef (diff) |
Improve RW-locking of template in shortcode handling
See #1599
Diffstat (limited to 'hugolib/shortcode.go')
-rw-r--r-- | hugolib/shortcode.go | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/hugolib/shortcode.go b/hugolib/shortcode.go index c49418b85..4d3037dc8 100644 --- a/hugolib/shortcode.go +++ b/hugolib/shortcode.go @@ -345,12 +345,12 @@ Loop: } // TODO(bep) Refactor/rename this lock strategy - isInnerShortcodeCache.Lock() + isInnerShortcodeCache.RLock() if tmpl.Tree == nil { - isInnerShortcodeCache.Unlock() + isInnerShortcodeCache.RUnlock() return sc, fmt.Errorf("Template for shortcode '%s' failed to compile for page '%s'", sc.name, p.BaseFileName()) } - isInnerShortcodeCache.Unlock() + isInnerShortcodeCache.RUnlock() isInner = isInnerShortcode(tmpl) case tScParam: @@ -523,6 +523,9 @@ func renderShortcodeWithPage(tmpl *template.Template, data *ShortcodeWithPage) s buffer := bp.GetBuffer() defer bp.PutBuffer(buffer) + // TODO(bep) Refactor/rename this lock strategy + isInnerShortcodeCache.Lock() + defer isInnerShortcodeCache.Unlock() err := tmpl.Execute(buffer, data) if err != nil { jww.ERROR.Println("error processing shortcode", tmpl.Name(), "\n ERR:", err) |