mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-28 04:39:56 +00:00
TUN-4456: Replaced instances of Tick() with Ticker() in h2mux paths
time.Tick() does not get garbage collected because the channel underneath never gets deleted and the underlying Ticker can never be recovered by the garbage collector. We replace this with NewTicker() to avoid this.
This commit is contained in:
@@ -69,12 +69,13 @@ func (r *MuxReader) run(log *zerolog.Logger) error {
|
||||
|
||||
// routine to periodically update bytesRead
|
||||
go func() {
|
||||
tickC := time.Tick(updateFreq)
|
||||
ticker := time.NewTicker(updateFreq)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
select {
|
||||
case <-r.abortChan:
|
||||
return
|
||||
case <-tickC:
|
||||
case <-ticker.C:
|
||||
r.metricsUpdater.updateInBoundBytes(r.bytesRead.Count())
|
||||
}
|
||||
}
|
||||
|
@@ -78,12 +78,13 @@ func (w *MuxWriter) run(log *zerolog.Logger) error {
|
||||
|
||||
// routine to periodically communicate bytesWrote
|
||||
go func() {
|
||||
tickC := time.Tick(updateFreq)
|
||||
ticker := time.NewTicker(updateFreq)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
select {
|
||||
case <-w.abortChan:
|
||||
return
|
||||
case <-tickC:
|
||||
case <-ticker.C:
|
||||
w.metricsUpdater.updateOutBoundBytes(w.bytesWrote.Count())
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user