]> source.dussan.org Git - gitea.git/commitdiff
Fix Workerpool deadlock (#10283) (#10284)
authorzeripath <art27@cantab.net>
Sat, 15 Feb 2020 19:28:25 +0000 (19:28 +0000)
committerGitHub <noreply@github.com>
Sat, 15 Feb 2020 19:28:25 +0000 (19:28 +0000)
* Prevent deadlock on boost

* Force a boost in testchannelqueue

modules/queue/queue_channel_test.go
modules/queue/workerpool.go

index fafc1e3303eb88f73668f5c0235884489b023cb7..fb5e5881d4c3edf729d13af365892ce34d21ca0c 100644 (file)
@@ -25,12 +25,13 @@ func TestChannelQueue(t *testing.T) {
 
        queue, err := NewChannelQueue(handle,
                ChannelQueueConfiguration{
-                       QueueLength:  20,
-                       Workers:      1,
+                       QueueLength:  0,
                        MaxWorkers:   10,
                        BlockTimeout: 1 * time.Second,
                        BoostTimeout: 5 * time.Minute,
                        BoostWorkers: 5,
+                       Workers:      0,
+                       Name:         "TestChannelQueue",
                }, &testData{})
        assert.NoError(t, err)
 
index 25fc7dd644254075e847e0650b1d464372866ff8..11115b0b7cd5306a718951d26809629aa7e7d898 100644 (file)
@@ -96,8 +96,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
                }
        }