Skip to content

Commit

Permalink
Ocpp: fix duplicate init (#16277)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Sep 23, 2024
1 parent 2d9a85b commit 0b0d8fd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions charger/ocpp/cs.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,13 @@ func (cs *CS) RegisterChargepoint(id string, newfun func() *CP, init func(*CP) e
cpmu.Lock()
defer cpmu.Unlock()

cp, err := cs.ChargepointByID(id)
if err != nil {
cp = newfun()
// already registered?
if cp, err := cs.ChargepointByID(id); err == nil {
return cp, nil
}

// should not error
// first time- registration should not error
cp := newfun()
if err := cs.register(id, cp); err != nil {
return nil, err
}
Expand Down

0 comments on commit 0b0d8fd

Please sign in to comment.