summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2022-12-30 00:06:47 +0000
committerGitHub <noreply@github.com>2022-12-30 02:06:47 +0200
commita609cae9fbdda5612da9e2ad84dd9afbcf2028ef (patch)
tree56544e27e34e523f5126266c8d7cb6f3c76612cd /routers
parent47efba78ec966631ccdea3e05a50f4cf59ca9fd3 (diff)
downloadgitea-a609cae9fbdda5612da9e2ad84dd9afbcf2028ef.tar.gz
gitea-a609cae9fbdda5612da9e2ad84dd9afbcf2028ef.zip
Correctly handle select on multiple channels in Queues (#22146)
There are a few places in FlushQueueWithContext which make an incorrect assumption about how `select` on multiple channels works. The problem is best expressed by looking at the following example: ```go package main import "fmt" func main() { closedChan := make(chan struct{}) close(closedChan) toClose := make(chan struct{}) count := 0 for { select { case <-closedChan: count++ fmt.Println(count) if count == 2 { close(toClose) } case <-toClose: return } } } ``` This PR double-checks that the contexts are closed outside of checking if there is data in the dataChan. It also rationalises the WorkerPool FlushWithContext because the previous implementation failed to handle pausing correctly. This will probably fix the underlying problem in #22145 Fix #22145 Signed-off-by: Andrew Thornton <art27@cantab.net> Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'routers')
0 files changed, 0 insertions, 0 deletions