summaryrefslogtreecommitdiffstats
path: root/modules/queue
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-02-15 18:44:58 +0000
committerGitHub <noreply@github.com>2020-02-15 18:44:58 +0000
commit88986746d51ef9bf7ea5d812bb889f8cc668b4f2 (patch)
tree974333233a8105c5e3a880f9ca52ae3b552bc396 /modules/queue
parent15614a83682f972bbe900cae935fdc47c4e80e2e (diff)
downloadgitea-88986746d51ef9bf7ea5d812bb889f8cc668b4f2.tar.gz
gitea-88986746d51ef9bf7ea5d812bb889f8cc668b4f2.zip
Fix Workerpool deadlock (#10283)
* Prevent deadlock on boost * Force a boost in testchannelqueue
Diffstat (limited to 'modules/queue')
-rw-r--r--modules/queue/queue_channel_test.go7
-rw-r--r--modules/queue/workerpool.go2
2 files changed, 6 insertions, 3 deletions
diff --git a/modules/queue/queue_channel_test.go b/modules/queue/queue_channel_test.go
index 8234b0f6f2..08a64c0ab8 100644
--- a/modules/queue/queue_channel_test.go
+++ b/modules/queue/queue_channel_test.go
@@ -26,16 +26,19 @@ func TestChannelQueue(t *testing.T) {
queue, err := NewChannelQueue(handle,
ChannelQueueConfiguration{
WorkerPoolConfiguration: WorkerPoolConfiguration{
- QueueLength: 20,
+ QueueLength: 0,
MaxWorkers: 10,
BlockTimeout: 1 * time.Second,
BoostTimeout: 5 * time.Minute,
BoostWorkers: 5,
},
- Workers: 1,
+ Workers: 0,
+ Name: "TestChannelQueue",
}, &testData{})
assert.NoError(t, err)
+ assert.Equal(t, queue.(*ChannelQueue).WorkerPool.boostWorkers, 5)
+
go queue.Run(nilFn, nilFn)
test1 := testData{"A", 1}
diff --git a/modules/queue/workerpool.go b/modules/queue/workerpool.go
index 63ec897481..952e87681e 100644
--- a/modules/queue/workerpool.go
+++ b/modules/queue/workerpool.go
@@ -132,8 +132,8 @@ func (p *WorkerPool) pushBoost(data Data) {
p.blockTimeout /= 2
p.lock.Unlock()
}()
- p.addWorkers(ctx, boost)
p.lock.Unlock()
+ p.addWorkers(ctx, boost)
p.dataChan <- data
}
}