From 52e6a63d8c987d6cad1a39a9b2505e990b0f682f Mon Sep 17 00:00:00 2001 From: Ainar Garipov Date: Fri, 21 May 2021 19:20:42 +0300 Subject: [PATCH] Pull request: all: fix race, imp scripts Merge in DNS/adguard-home from fix-race to master Squashed commit of the following: commit dff47c707554f689cf131e0ab3fe05df4e4b6a51 Author: Ainar Garipov Date: Fri May 21 19:12:06 2021 +0300 all: fix race, imp scripts --- internal/aghnet/etchostscontainer.go | 6 +++++- scripts/make/build-docker.sh | 2 -- scripts/make/clean.sh | 3 +-- scripts/make/go-lint.sh | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/internal/aghnet/etchostscontainer.go b/internal/aghnet/etchostscontainer.go index 1d32d584..9cb17c83 100644 --- a/internal/aghnet/etchostscontainer.go +++ b/internal/aghnet/etchostscontainer.go @@ -121,7 +121,9 @@ func (ehc *EtcHostsContainer) Close() { if ehc.watcher != nil { _ = ehc.watcher.Close() } - close(ehc.onlyWritesChan) + + // Don't close onlyWritesChan here and let onlyWrites close it after + // watcher.Events is closed to prevent close races. } // Process returns the list of IP addresses for the hostname or nil if nothing @@ -298,6 +300,8 @@ func (ehc *EtcHostsContainer) onlyWrites() { ehc.onlyWritesChan <- event } } + + close(ehc.onlyWritesChan) } // Receive notifications from fsnotify package diff --git a/scripts/make/build-docker.sh b/scripts/make/build-docker.sh index 138c30dd..df1050e6 100644 --- a/scripts/make/build-docker.sh +++ b/scripts/make/build-docker.sh @@ -27,8 +27,6 @@ else fi readonly version -echo $version - # Allow users to use sudo. sudo_cmd="${SUDO:-}" readonly sudo_cmd diff --git a/scripts/make/clean.sh b/scripts/make/clean.sh index 85301ec1..7fee73f0 100644 --- a/scripts/make/clean.sh +++ b/scripts/make/clean.sh @@ -11,9 +11,8 @@ fi set -e -f -u dist_dir="$DIST_DIR" -go="${GO:-go}" sudo_cmd="${SUDO:-}" -readonly dist_dir go sudo_cmd +readonly dist_dir sudo_cmd $sudo_cmd rm -f\ ./AdGuardHome\ diff --git a/scripts/make/go-lint.sh b/scripts/make/go-lint.sh index c1f14572..e0164612 100644 --- a/scripts/make/go-lint.sh +++ b/scripts/make/go-lint.sh @@ -136,7 +136,7 @@ exit_on_output() ( then if [ "$*" != '' ] then - echo "combined output of '$cmd $@':" + echo "combined output of '$cmd $*':" else echo "combined output of '$cmd':" fi