Skip to content

Commit

Permalink
Merge branch 'master' into gabrielcorado/move-shared-db-srvconnect-fu…
Browse files Browse the repository at this point in the history
…nctions
  • Loading branch information
gabrielcorado authored Dec 2, 2024
2 parents 05ac723 + 381704f commit 4d48117
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/inventory/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,11 @@ func (c *Controller) RegisterControlStream(stream client.UpstreamInventoryContro
c.store.Insert(handle)

// Increment the concurrent connection counter that we use to calculate the
// variable instance heartbeat duration. It's done here synchronously rather
// than in handleControlStream for the sake of tests.
// variable instance heartbeat duration. To make the behavior more easily
// testable, we increment it here and we decrement it before closing the
// stream in handleControlStream.
c.instanceHBVariableDuration.Inc()
go func() {
defer c.instanceHBVariableDuration.Dec()
c.handleControlStream(handle)
}()
go c.handleControlStream(handle)
}

// GetControlStream gets a control stream for the given server ID if one exists (if multiple control streams
Expand Down Expand Up @@ -400,6 +398,7 @@ func (c *Controller) handleControlStream(handle *upstreamHandle) {
}
}

c.instanceHBVariableDuration.Dec()
for _, service := range handle.hello.Services {
c.serviceCounter.decrement(service)
}
Expand Down

0 comments on commit 4d48117

Please sign in to comment.