Skip to content

Commit

Permalink
Merge pull request #2008 from openziti/fix-ert-heartbeats
Browse files Browse the repository at this point in the history
HA update broken heartbeat reporting for xgress_edge_tunnel api sessions. Fixes #2007
  • Loading branch information
plorenz authored May 1, 2024
2 parents d244882 + 09d8f42 commit 611f64c
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions router/state/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,12 +605,7 @@ func (sm *ManagerImpl) StartHeartbeat(env env.RouterEnv, intervalSeconds int, cl
}

func (sm *ManagerImpl) AddConnectedApiSession(token string) {
sm.activeApiSessions.Upsert(token, nil, func(exist bool, valueInMap *MapWithMutex, newValue *MapWithMutex) *MapWithMutex {
if exist {
return valueInMap
}
return newMapWithMutex()
})
sm.activeApiSessions.Set(token, nil)
}

func (sm *ManagerImpl) RemoveConnectedApiSession(token string) {
Expand Down Expand Up @@ -657,18 +652,24 @@ func (sm *ManagerImpl) ActiveApiSessionTokens() []string {
var toClose []func()
var activeKeys []string
for i := range sm.activeApiSessions.IterBuffered() {
func() {
token := i.Key
chMutex := i.Val

token := i.Key
chMutex := i.Val
if chMutex == nil {
// An xgress_edge_tunnel api-session won't have associated channels
activeKeys = append(activeKeys, token)
} else {
chMutex.Visit(func(ch channel.Channel, closeCb func()) {
if ch.IsClosed() {
toClose = append(toClose, closeCb)
} else {
activeKeys = append(activeKeys, token)
}
})
}()
}
}

for _, f := range toClose {
f()
}

return activeKeys
Expand Down

0 comments on commit 611f64c

Please sign in to comment.