Skip to content

Commit

Permalink
move clear stats
Browse files Browse the repository at this point in the history
  • Loading branch information
menghanl committed Apr 25, 2017
1 parent c8d2d9d commit f41c688
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion grpclb.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ func (b *balancer) processServerList(l *lbpb.ServerList, seq int) {
}

func (b *balancer) sendLoadReport(s *balanceLoadClientStream, interval time.Duration, done <-chan struct{}) {
b.clientStats = lbpb.ClientStats{} // Clear client stats.
ticker := time.NewTicker(interval)
defer ticker.Stop()
for {
Expand Down Expand Up @@ -355,6 +354,9 @@ func (b *balancer) callRemoteBalancer(lbc *loadBalancerClient, seq int) (retry b
}
streamDone := make(chan struct{})
defer close(streamDone)
b.mu.Lock()
b.clientStats = lbpb.ClientStats{} // Clear client stats.
b.mu.Unlock()
if d := convertDuration(initResp.ClientStatsReportInterval); d > 0 {
go b.sendLoadReport(stream, d, streamDone)
}
Expand Down

0 comments on commit f41c688

Please sign in to comment.