Skip to content

Commit

Permalink
commands: Fix server deadlock on config error
Browse files Browse the repository at this point in the history
Fixes #9486
  • Loading branch information
bep committed Feb 10, 2022
1 parent f7bc4cc commit a2a660e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions commands/commandeer.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ type commandeer struct {
logger loggers.Logger
serverConfig *config.Server

buildLock func() (unlock func(), err error)

// Loading state
mustHaveConfigFile bool
failOnInitErr bool
Expand Down Expand Up @@ -419,6 +421,10 @@ func (c *commandeer) loadConfig() error {
err = createErr
}
c.hugoSites = h
// TODO(bep) improve.
if c.buildLock == nil {
c.buildLock = h.LockBuild
}
close(c.created)
})

Expand Down
2 changes: 1 addition & 1 deletion commands/hugo.go
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ func (c *commandeer) newWatcher(pollIntervalStr string, dirList ...string) (*wat
for {
select {
case evs := <-watcher.Events:
unlock, err := c.hugo().BaseFs.LockBuild()
unlock, err := c.buildLock()
if err != nil {
c.logger.Errorln("Failed to acquire a build lock: %s", err)
return
Expand Down

0 comments on commit a2a660e

Please sign in to comment.