diff options
author | zeripath <art27@cantab.net> | 2022-04-27 00:22:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-26 19:22:26 -0400 |
commit | 41fcf7b7dee49021fca190c0ad7fe6bfb6e400b0 (patch) | |
tree | 32e697c102279d33d14e8a6eca2f91a40bd1e874 /modules/indexer | |
parent | 3fbaa79c6e0964d01c21609a97b202df24eb7daf (diff) | |
download | gitea-41fcf7b7dee49021fca190c0ad7fe6bfb6e400b0.tar.gz gitea-41fcf7b7dee49021fca190c0ad7fe6bfb6e400b0.zip |
Prevent dangling archiver goroutine (#19516)
Within doArchive there is a service goroutine that performs the
archiving function. This goroutine reports its error using a `chan
error` called `done`. Prior to this PR this channel had 0 capacity
meaning that the goroutine would block until the `done` channel was
cleared - however there are a couple of ways in which this channel might
not be read.
The simplest solution is to add a single space of capacity to the
goroutine which will mean that the goroutine will always complete and
even if the `done` channel is not read it will be simply garbage
collected away.
(The PR also contains two other places when setting up the indexers
which do not leak but where the blocking of the sending goroutine is
also unnecessary and so we should just add a small amount of capacity
and let the sending goroutine complete as soon as it can.)
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'modules/indexer')
-rw-r--r-- | modules/indexer/code/indexer.go | 2 | ||||
-rw-r--r-- | modules/indexer/issues/indexer.go | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/modules/indexer/code/indexer.go b/modules/indexer/code/indexer.go index 3ead3261e9..f15b8d8651 100644 --- a/modules/indexer/code/indexer.go +++ b/modules/indexer/code/indexer.go @@ -133,7 +133,7 @@ func Init() { finished() }) - waitChannel := make(chan time.Duration) + waitChannel := make(chan time.Duration, 1) // Create the Queue switch setting.Indexer.RepoType { diff --git a/modules/indexer/issues/indexer.go b/modules/indexer/issues/indexer.go index 8ca9975c7b..d4df4f8a4f 100644 --- a/modules/indexer/issues/indexer.go +++ b/modules/indexer/issues/indexer.go @@ -104,7 +104,7 @@ var ( func InitIssueIndexer(syncReindex bool) { ctx, _, finished := process.GetManager().AddTypedContext(context.Background(), "Service: IssueIndexer", process.SystemProcessType, false) - waitChannel := make(chan time.Duration) + waitChannel := make(chan time.Duration, 1) // Create the Queue switch setting.Indexer.IssueType { |