Skip to content

Commit

Permalink
apply suggestion
Browse files Browse the repository at this point in the history
apply suggestion
  • Loading branch information
jiuker committed Jul 10, 2024
1 parent b0739f2 commit 1a634ec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,9 @@ func (b *Backend) updateCallStats(t shortTraceMsg) {
// automatically update the global stats
// Read/Write Lock is not required here
globalConnStatsRWMutex.RLock()
for _, c := range globalConnStats {
connStats := globalConnStats
globalConnStatsRWMutex.RUnlock()
for _, c := range connStats {
if c == nil {
continue
}
Expand All @@ -418,7 +420,6 @@ func (b *Backend) updateCallStats(t shortTraceMsg) {
c.setTotalCalls(b.Stats.TotCalls)
c.setTotalCallFailures(b.Stats.TotCallFailures)
}
globalConnStatsRWMutex.RUnlock()
}

type multisite struct {
Expand Down
5 changes: 3 additions & 2 deletions metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ func (c *sidekickCollector) Collect(ch chan<- prometheus.Metric) {
// automatically read the global stats
// Read/Write Lock is not required here
globalConnStatsRWMutex.RLock()
defer globalConnStatsRWMutex.RUnlock()
for _, c := range globalConnStats {
connStats := globalConnStats
globalConnStatsRWMutex.RUnlock()
for _, c := range connStats {
if c == nil {
continue
}
Expand Down

0 comments on commit 1a634ec

Please sign in to comment.