]> source.dussan.org Git - gitea.git/commitdiff
fix datarace on issue indexer queue (#9490)
authorLunny Xiao <xiaolunwen@gmail.com>
Wed, 25 Dec 2019 09:44:09 +0000 (17:44 +0800)
committerGitHub <noreply@github.com>
Wed, 25 Dec 2019 09:44:09 +0000 (17:44 +0800)
modules/indexer/code/indexer.go
modules/indexer/code/queue.go

index 04d556f541f9de80053c6c724ebb38a211f0602a..3f9461cd0e58ca76e911e48b17f4df806bcb41e7 100644 (file)
@@ -38,6 +38,8 @@ func Init() {
                return
        }
 
+       initQueue(setting.Indexer.UpdateQueueLength)
+
        ctx, cancel := context.WithCancel(context.Background())
 
        graceful.GetManager().RunAtTerminate(ctx, func() {
index 82cd8ded53937dcef5bdbdd31fbda6a006232d15..4eeb6ac7d40464722ac6bc6f10e912cce6cedfbe 100644 (file)
@@ -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: