diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2019-12-25 17:44:09 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-25 17:44:09 +0800 |
commit | 8b2f29c0d2e571b45f004646d3b5e6bac1c2c419 (patch) | |
tree | 2756a191d78ab576b3042109ac6572f956aa7f53 /modules/indexer | |
parent | f88715e29c8cd6865b69eb8e692d051d977e93a5 (diff) | |
download | gitea-8b2f29c0d2e571b45f004646d3b5e6bac1c2c419.tar.gz gitea-8b2f29c0d2e571b45f004646d3b5e6bac1c2c419.zip |
fix datarace on issue indexer queue (#9490)
Diffstat (limited to 'modules/indexer')
-rw-r--r-- | modules/indexer/code/indexer.go | 2 | ||||
-rw-r--r-- | modules/indexer/code/queue.go | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/modules/indexer/code/indexer.go b/modules/indexer/code/indexer.go index 04d556f541..3f9461cd0e 100644 --- a/modules/indexer/code/indexer.go +++ b/modules/indexer/code/indexer.go @@ -38,6 +38,8 @@ func Init() { return } + initQueue(setting.Indexer.UpdateQueueLength) + ctx, cancel := context.WithCancel(context.Background()) graceful.GetManager().RunAtTerminate(ctx, func() { diff --git a/modules/indexer/code/queue.go b/modules/indexer/code/queue.go index 82cd8ded53..4eeb6ac7d4 100644 --- a/modules/indexer/code/queue.go +++ b/modules/indexer/code/queue.go @@ -21,8 +21,11 @@ type repoIndexerOperation struct { var repoIndexerOperationQueue chan repoIndexerOperation +func initQueue(queueLength int) { + repoIndexerOperationQueue = make(chan repoIndexerOperation, queueLength) +} + func processRepoIndexerOperationQueue(indexer Indexer) { - repoIndexerOperationQueue = make(chan repoIndexerOperation, setting.Indexer.UpdateQueueLength) for { select { case op := <-repoIndexerOperationQueue: |