Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: SA1015: using time.Tick leaks the underlying ticker #35

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions remote/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,12 +617,12 @@ func attachWpCliCmdRemote(conn net.Conn, wpcli *wpCLIProcess, GUID string, rows
log.Printf("attachWpCliCmdRemote: Catchup_Loop finished ")

// Used to monitor when the connection is disconnected or the CLI command finishes
ticker := time.Tick(time.Duration(500 * time.Millisecond.Nanoseconds()))
ticker := time.NewTicker(time.Duration(500 * time.Millisecond.Nanoseconds()))

Watcher_Loop:
for {
select {
case <-ticker:
case <-ticker.C:
if !connectionActive {
log.Println("attachWpCliCmdRemote: ticker: client connection is closed, exiting this watcher loop")
break Watcher_Loop
Expand Down Expand Up @@ -788,12 +788,12 @@ func runWpCliCmdRemote(conn net.Conn, GUID string, rows uint16, cols uint16, wpC
var buf []byte = make([]byte, 8192)

// Used to monitor when the connection is disconnected or the CLI command finishes
ticker := time.Tick(time.Duration(500 * time.Millisecond.Nanoseconds()))
ticker := time.NewTicker(time.Duration(500 * time.Millisecond.Nanoseconds()))

Exit_Loop:
for {
select {
case <-ticker:
case <-ticker.C:
if nil == conn {
log.Println("runWpCliCmdRemote ticker: client connection is closed, exiting this watcher loop")
break Exit_Loop
Expand Down
Loading