Fix another deadlock

This commit is contained in:
andig 2024-06-09 11:56:34 +02:00
parent ebaa42f405
commit 4b3d83f2b5
2 changed files with 6 additions and 7 deletions

View file

@ -947,8 +947,7 @@ CONTINUE:
func configureSite(conf map[string]interface{}, loadpoints []*core.Loadpoint, tariffs *tariff.Tariffs) (*core.Site, error) {
site, err := core.NewSiteFromConfig(conf)
if err != nil {
// TODO proper handling
panic(err)
return nil, err
}
if err := site.Boot(log, loadpoints, tariffs); err != nil {

View file

@ -13,7 +13,7 @@ import (
)
var (
mu sync.Mutex
mu sync.RWMutex
Subject, Token string
ExpiresAt time.Time
)
@ -24,14 +24,14 @@ const (
)
func IsAuthorized() bool {
mu.Lock()
defer mu.Unlock()
mu.RLock()
defer mu.RUnlock()
return len(Subject) > 0
}
func IsAuthorizedForApi() bool {
mu.Lock()
defer mu.Unlock()
mu.RLock()
defer mu.RUnlock()
return IsAuthorized() && Subject != unavailable && Token != ""
}