Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 37ad03f

Browse files
committed
Block on sending stat updates
1 parent 99d7d1a commit 37ad03f

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

agent/agent.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,14 +1272,11 @@ func (a *agent) startReportingConnectionStats(ctx context.Context) {
12721272
a.logger.Info(ctx, "skipping stat because nothing changed")
12731273
return
12741274
}
1275+
a.latestStat.Store(stats)
12751276

12761277
select {
12771278
case a.connStatsChan <- stats:
1278-
// Only store the latest stat when it's successfully sent!
1279-
// Otherwise, it should be sent again on the next iteration.
1280-
a.latestStat.Store(stats)
1281-
default:
1282-
a.logger.Warn(ctx, "network stat dropped")
1279+
case <-a.closed:
12831280
}
12841281
}
12851282

0 commit comments

Comments
 (0)