Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-12-11 14:01:58 +01:00
forgejo/modules/queue
zeripath a609cae9fb
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>
2022-12-30 02:06:47 +02:00
..
bytefifo.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
helper.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
manager.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
queue.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
queue_bytefifo.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
queue_channel.go Correctly handle select on multiple channels in Queues (#22146) 2022-12-30 02:06:47 +02:00
queue_channel_test.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
queue_disk.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
queue_disk_channel.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
queue_disk_channel_test.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
queue_disk_test.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
queue_redis.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
queue_test.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
queue_wrapped.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
setting.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
unique_queue.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
unique_queue_channel.go Correctly handle select on multiple channels in Queues (#22146) 2022-12-30 02:06:47 +02:00
unique_queue_channel_test.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
unique_queue_disk.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
unique_queue_disk_channel.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
unique_queue_redis.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
unique_queue_wrapped.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
workerpool.go Correctly handle select on multiple channels in Queues (#22146) 2022-12-30 02:06:47 +02:00