]> source.dussan.org Git - gitea.git/commit
Prevent timer leaks in Workerpool and others (#11333) (#11340)
authorzeripath <art27@cantab.net>
Fri, 8 May 2020 16:18:39 +0000 (17:18 +0100)
committerGitHub <noreply@github.com>
Fri, 8 May 2020 16:18:39 +0000 (00:18 +0800)
commit86863ae9395b77163dda50eb3a141877eb95eb12
treed1639e2dedf759b21483ba63f6d43ee8bcf90823
parentf3a90057a53924640d4863c2c49c5b11bc7bb891
Prevent timer leaks in Workerpool and others (#11333) (#11340)

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>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
cmd/hook.go
modules/migrations/github.go
modules/queue/queue_wrapped.go
modules/queue/workerpool.go
modules/util/timer.go [new file with mode: 0644]