summaryrefslogtreecommitdiff
path: root/context.go
diff options
context:
space:
mode:
authorMatt Holt <mholt@users.noreply.github.com>2023-07-21 15:32:20 -0600
committerGitHub <noreply@github.com>2023-07-21 15:32:20 -0600
commitb51dc5d5d0b8764165170af1f54b77d6de8cb5a1 (patch)
treed94262de1f318855c1cb723dd84ff4de3e96b6c4 /context.go
parentf857b32d65de882dbc945c94029849a7fc895e36 (diff)
core: Refine mutex during reloads (fix #5628) (#5645)
Separate currentCtxMu to protect currentCtx, and a new rawCfgMu to protect rawCfg and synchronize loads.
Diffstat (limited to 'context.go')
-rw-r--r--context.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/context.go b/context.go
index 004dee6..85978d4 100644
--- a/context.go
+++ b/context.go
@@ -441,6 +441,12 @@ func (ctx Context) App(name string) (any, error) {
// or stop App modules. The caller is expected to assert to the
// concrete type.
func (ctx Context) AppIfConfigured(name string) any {
+ if ctx.cfg == nil {
+ // this can happen if the currently-active context
+ // is being accessed, but no config has successfully
+ // been loaded yet
+ return nil
+ }
return ctx.cfg.apps[name]
}