Skip to content

Commit

Permalink
Loadpoint: relax locking (#18256)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored Jan 17, 2025
1 parent 6cdd844 commit a67601c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions core/loadpoint_phases.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ func (lp *Loadpoint) ActivePhases() int {

// minActivePhases returns the minimum number of active phases for the loadpoint.
func (lp *Loadpoint) minActivePhases() int {
lp.Lock()
lp.RLock()
configuredPhases := lp.configuredPhases
lp.Unlock()
lp.RUnlock()

// 1p3p supported or limit 1p
if lp.hasPhaseSwitching() || configuredPhases == 1 {
Expand All @@ -102,9 +102,9 @@ func (lp *Loadpoint) maxActivePhases() int {

// if 1p3p supported then assume configured limit or 3p
if lp.hasPhaseSwitching() {
lp.Lock()
lp.RLock()
physical = lp.configuredPhases
lp.Unlock()
lp.RUnlock()
}

return min(expect(vehicle), expect(physical), expect(measured), expect(charger))
Expand Down

0 comments on commit a67601c

Please sign in to comment.