summaryrefslogtreecommitdiffstats
path: root/hugolib/hugo_sites.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-05-18 08:38:58 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-05-18 09:01:40 +0200
commit95ce2a40e734bb82b69f9a64270faf3ed69c92cc (patch)
tree3391ca7d88672042ae5e2ef8f764797cbc381325 /hugolib/hugo_sites.go
parenta83256b9cd5c50dde1a086a48f365a1fcbc78a24 (diff)
hugolib: Prevent parallel server rebuilds
There have been reports about infrequent paginator crashes when running the Hugo server since 0.55.0. The reason have been narrowed down to that of parallel rebuilds. This isn't a new thing, but the changes in 0.55.0 made it extra important to serialize the page initialization. This commit fixes that by protecting the `Build` method with a lock when running in server mode. Fixes #5885 Fixes #5968
Diffstat (limited to 'hugolib/hugo_sites.go')
-rw-r--r--hugolib/hugo_sites.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/hugolib/hugo_sites.go b/hugolib/hugo_sites.go
index 6f95dbb12..5be4ec02b 100644
--- a/hugolib/hugo_sites.go
+++ b/hugolib/hugo_sites.go
@@ -62,6 +62,9 @@ type HugoSites struct {
// If this is running in the dev server.
running bool
+ // Serializes rebuilds when server is running.
+ runningMu sync.Mutex
+
// Render output formats for all sites.
renderFormats output.Formats