Pull request 1806: 5661-fix-protection-update-lock

Updates #5661.

Squashed commit of the following:

commit 02e83c75c8f44f084c0cb8d33b7d6a524c8c1b0e
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Thu Apr 6 19:28:17 2023 +0300

    dnsforward: imp logs

commit 0f27265fc94f0e3b8e2dee79dbf9ab5344416c61
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Thu Apr 6 19:18:19 2023 +0300

    dnsforward: imp locks
This commit is contained in:
Ainar Garipov
2023-04-06 19:33:25 +03:00
parent b1120221c7
commit 5d5a729569
2 changed files with 36 additions and 15 deletions

View File

@@ -9,6 +9,7 @@ import (
"runtime"
"strings"
"sync"
"sync/atomic"
"time"
"github.com/AdguardTeam/AdGuardHome/internal/aghalg"
@@ -111,6 +112,10 @@ type Server struct {
isRunning bool
// protectionUpdateInProgress is used to make sure that only one goroutine
// updating the protection configuration after a pause is running at a time.
protectionUpdateInProgress atomic.Bool
conf ServerConfig
// serverLock protects Server.
serverLock sync.RWMutex