Skip to content

Commit

Permalink
fix datarace on issue indexer queue (#9490)
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny authored Dec 25, 2019
1 parent f88715e commit 8b2f29c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions modules/indexer/code/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ func Init() {
return
}

initQueue(setting.Indexer.UpdateQueueLength)

ctx, cancel := context.WithCancel(context.Background())

graceful.GetManager().RunAtTerminate(ctx, func() {
Expand Down
5 changes: 4 additions & 1 deletion modules/indexer/code/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 8b2f29c

Please sign in to comment.