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

Streams should check for Session shutdown when waiting for data & clean up timers #127

Merged
Merged
Changes from 1 commit
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
Prev Previous commit
Drain the timer's channel if needed, to prevent memory leakage
When stopping a time.Timer, you need to check the return value and drain
the channel to prevent a memory leak, if the Timer has fired.
  • Loading branch information
lattwood committed Aug 21, 2024
commit 84b3fc617bb1d13ae6b0b6850f734049e9605060
8 changes: 6 additions & 2 deletions stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ WAIT:
return 0, ErrTimeout
}
if timer != nil {
timer.Stop()
if !timer.Stop() {
<-timeout
}
}
goto START
}
Expand Down Expand Up @@ -234,7 +236,9 @@ WAIT:
return 0, ErrTimeout
}
if timer != nil {
timer.Stop()
if !timer.Stop() {
<-timeout
}
}
goto START
}
Expand Down
Loading