From 41fcf7b7dee49021fca190c0ad7fe6bfb6e400b0 Mon Sep 17 00:00:00 2001 From: zeripath Date: Wed, 27 Apr 2022 00:22:26 +0100 Subject: 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 Co-authored-by: 6543 <6543@obermui.de> --- modules/indexer/code/indexer.go | 2 +- modules/indexer/issues/indexer.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'modules/indexer') 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 { -- cgit v1.2.3