Skip to content

Prevent timer leaks in Workerpool and others (#11333)#11340

Merged
lunny merged 1 commit into
go-gitea:release/v1.11from
zeripath:backport-11333
May 8, 2020
Merged

Prevent timer leaks in Workerpool and others (#11333)#11340
lunny merged 1 commit into
go-gitea:release/v1.11from
zeripath:backport-11333

Conversation

@zeripath
Copy link
Copy Markdown
Contributor

@zeripath zeripath commented May 8, 2020

There is a potential memory leak in Workerpool due to the intricacies of
time.Timer stopping.

Whenever a time.Timer is Stopped its channel must be cleared using a
select if the result of the Stop() is false.

Unfortunately in Workerpool these were checked the wrong way round.

However, there were a few other places that were not being checked.

Signed-off-by: Andrew Thornton art27@cantab.net

Co-authored-by: techknowlogick techknowlogick@gitea.io
Co-authored-by: Lunny Xiao xiaolunwen@gmail.com

There is a potential memory leak in `Workerpool` due to the intricacies of
`time.Timer` stopping.

Whenever a `time.Timer` is `Stop`ped its channel must be cleared using a
`select` if the result of the `Stop()` is `false`.

Unfortunately in `Workerpool` these were checked the wrong way round.

However, there were a few other places that were not being checked.

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
@zeripath zeripath added this to the 1.11.5 milestone May 8, 2020
@GiteaBot GiteaBot added the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label May 8, 2020
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels May 8, 2020
@lunny lunny merged commit 86863ae into go-gitea:release/v1.11 May 8, 2020
@zeripath zeripath deleted the backport-11333 branch May 8, 2020 16:50
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants