]> source.dussan.org Git - gitea.git/commitdiff
services: archiver: appease golangci-lint, lock queueMutex
authorKyle Evans <kevans@FreeBSD.org>
Tue, 5 May 2020 21:56:39 +0000 (16:56 -0500)
committerKyle Evans <kevans@FreeBSD.org>
Tue, 5 May 2020 21:56:39 +0000 (16:56 -0500)
Locking/unlocking the queueMutex is allowed, but not required, for
Cond.Signal() and Cond.Broadcast().  The magic at play here is just a little
too much for golangci-lint, as we take the address of queueMutex and this is
mostly used in archiver.go; the variable still gets flagged as unused.

services/archiver/archiver_test.go

index 71a4fb905b6f989a3c4a06aa0f2e243f39887022..bfeeb24f1e7863ce7f4a4875aa30b2d44244c394 100644 (file)
@@ -43,7 +43,9 @@ func releaseOneEntry(t *testing.T, inFlight []*ArchiveRequest) {
        numQueued = len(archiveInProgress)
 
        // Release one, then wait up to 3 seconds for it to complete.
+       queueMutex.Lock()
        archiveQueueReleaseCond.Signal()
+       queueMutex.Unlock()
        timeout := time.Now().Add(3 * time.Second)
        for {
                nowQueued = len(archiveInProgress)
@@ -117,7 +119,9 @@ func TestArchive_Basic(t *testing.T) {
 
        // Release them all, they'll then stall at the archiveQueueReleaseCond while
        // we examine the queue state.
+       queueMutex.Lock()
        archiveQueueStartCond.Broadcast()
+       queueMutex.Unlock()
 
        // 8 second timeout for them all to complete.
        timeout := time.Now().Add(8 * time.Second)